RogerDodger
New Member
- Joined
- Aug 22, 2007
- Messages
- 5
This forum is great. Thanks for taking the time to read my question. I am making a copy of a worksheet contained in the host workbook, which creates a new workbook (export workbook). I save the export workbook and have two workbooks open. I activate the host workbook and export a module from it then activate the export workbook and import the module into it however it is importing into the host not the export worbook. I have a feeling activating a workbook does not necessarily change the activeVBproject however this is just a guess. Here is the code I have so far. Thanks to all for your time and effort.
Workbooks(Host).Activate
ActiveWorkbook.VBProject.VBComponents("ResetXFER1").Export ("C:\ResetXFER1.bas")
Workbooks(NWBN).Activate: Sheets("Upload_Template").Select '<-----maybe this is not activating the VBproject???
Application.VBE.ActiveVBProject.VBComponents.Import ("C:\ResetXFER1.bas
In case it helps, here is a larger snippet of code...
Sub ExportReport()
'010 Miscl presets
On Error GoTo ExportdbErrorTrap
Host = ActiveWorkbook.Name
Application.StatusBar = "Exporting..... for job " & C14 - 4
'020 Append text to filename
Append1 = Now
Append1 = Replace(Append1, "/", "-") 'make filename legal
Append1 = Replace(Append1, ":", ".")
NWBN = "ExportName " & Append1 & ".xls"
'040 Create new workbook
On Error GoTo 0
Sheets("Upload_Template").Select
Sheets("Upload_Template").Copy
ActiveWorkbook.SaveAs (NWBN)
'050 Export and Import Macro (for new workbook)
Workbooks(Host).Activate
ActiveWorkbook.VBProject.VBComponents("ResetXFER1").Export ("C:\ResetXFER1.bas")
Workbooks(NWBN).Activate: Sheets("Upload_Template").Select
Application.VBE.ActiveVBProject.VBComponents.Import ("C:\ResetXFER1.bas")
ActiveWorkbook.Save
ActiveWorkbook.Close
End Sub
Workbooks(Host).Activate
ActiveWorkbook.VBProject.VBComponents("ResetXFER1").Export ("C:\ResetXFER1.bas")
Workbooks(NWBN).Activate: Sheets("Upload_Template").Select '<-----maybe this is not activating the VBproject???
Application.VBE.ActiveVBProject.VBComponents.Import ("C:\ResetXFER1.bas
In case it helps, here is a larger snippet of code...
Sub ExportReport()
'010 Miscl presets
On Error GoTo ExportdbErrorTrap
Host = ActiveWorkbook.Name
Application.StatusBar = "Exporting..... for job " & C14 - 4
'020 Append text to filename
Append1 = Now
Append1 = Replace(Append1, "/", "-") 'make filename legal
Append1 = Replace(Append1, ":", ".")
NWBN = "ExportName " & Append1 & ".xls"
'040 Create new workbook
On Error GoTo 0
Sheets("Upload_Template").Select
Sheets("Upload_Template").Copy
ActiveWorkbook.SaveAs (NWBN)
'050 Export and Import Macro (for new workbook)
Workbooks(Host).Activate
ActiveWorkbook.VBProject.VBComponents("ResetXFER1").Export ("C:\ResetXFER1.bas")
Workbooks(NWBN).Activate: Sheets("Upload_Template").Select
Application.VBE.ActiveVBProject.VBComponents.Import ("C:\ResetXFER1.bas")
ActiveWorkbook.Save
ActiveWorkbook.Close
End Sub