Ed
Workbooks("Custom Workbook1").Sheets.Copy Before:=Workbooks("Custom Workbook2").Sheets(1)
Celia
Now I want to copy a Macro (Module 1) from Custom Workbook1 over to Custom Workbook2. I can do it with export and import mannually, but can't seem to get the VBA code right to do it within the Macro - and it doesn't record when I do it manually (darn it!)
Any Clues?
Re: Thanks Celia - Now...
Ed
Sub CopyModule()
Workbooks("Custom Workbook1").VBProject.VBComponents("Module1") _
.Export Filename:="C:\My Documents\new.bas"
Workbooks("Custom Workbook2").VBProject.VBComponents _
.Import(Filename:="C:\My Documents\new.bas").Name = "NewModule"
Kill "C:\My Documents\new.bas"
End Sub
Celia
To use the above code, you must have a reference set to the VBA Extensibility library.
In the VBA editor, go to Tools, References, and check "Microsoft Visual Basic For Application Extensibility".
celia