I have some code that is successfully pulling the required sheets into a new workbook and saving said workbook in same location as the source workbook. However, I cant get the modules to copy over as well. When I run this code, I get no errors, but the Modules dont copy over to new workbook either. Please advise.
Dim path As String
Dim filename1 As String
filename1 = Worksheets("Instructions").Range("P1").Text & " Tech Eval"
path = ThisWorkbook.path & ""
Worksheets(Array("Narrative", "Summary Page", "Exceptions", "Offer Rating Sheet")).Copy
With ActiveWorkbook
.SaveAs Filename:=path & filename1, FileFormat:=xlOpenXMLWorkbookMacroEnabled
End With
Dim strFolder As String, strTempFile As String
strFolder = ActiveWorkbook.path
If Len(strFolder) = 0 Then strFolder = CurDir
strFolder = strFolder & ""
strTempFile = strFolder & "~tmpexport.bas"
On Error Resume Next
ActiveWorkbook.VBProject.VBComponents("Module2").Export strTempFile
Workbooks(filename1).VBProject.VBComponents.import strTempFile
Kill strTempFile