Guest User

Untitled

a guest
Nov 16th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. Dim ct
  2. Dim strDesktopPath
  3.  
  4. On Error Resume Next
  5. ct = Application.InputBox("Enter Contract Number (5555, 6666, 7777)", "Save As")
  6. strDesktopPath = objWS.SpecialFolders("Desktop")
  7. If ct = "5555" Then
  8. Sheet1.Select
  9. Sheet2.Select
  10. Sheet3.Select
  11. Sheet4.Select
  12. Sheet5.Select
  13. Selection.Cells.Copy
  14. With ActiveWorkbook
  15. .SaveCopyAs Filename:=strDesktopPath & "" & ct & " Report.xls"
  16. End With
  17.  
  18. Dim VBProj As VBIDE.VBProject
  19. Dim VBComp As VBIDE.VBComponent
  20. Dim CodeMod As VBIDE.CodeModule
  21. Set VBProj = ActiveWorkbook.VBProject
  22.  
  23. Set objWS = CreateObject("WScript.Shell")
  24. For Each VBComp In VBProj.VBComponents
  25. If VBComp.Type = vbext_ct_Document Then
  26. Set CodeMod = VBComp.CodeModule
  27. With CodeMod
  28. .DeleteLines 1, .CountOfLines
  29. End With
  30. Else
  31. VBProj.VBComponents.Remove VBComp
  32. End If
  33. Next VBComp
Add Comment
Please, Sign In to add comment