How do I copy macro into new workbook that was created automatica.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am creating a new workbook with a macro. I want the macro to be copied to
the new workbook too automatically so I can run that macro again from the new
workbook.
 
Here how I do it with one of my projects.


With Workbooks("PERSONAL.XLS").VBProject
..VBComponents("FollowUpSupport").Export
("h:\Macros\FollowUpSupport.bas")
..VBComponents("ProjectSupport").Export
("h:\Macros\ProjectSupport.bas")
..VBComponents("PSSupport").Export ("h:\Macros\PSSupport.bas")
..VBComponents("PSLogin").Export ("h:\Macros\PSLogin.frm")
End With

With neoBook
..VBProject.VBComponents.Import "h:\Macros\FollowUpSupport.bas"
..VBProject.VBComponents.Import "h:\Macros\ProjectSupport.bas"
..VBProject.VBComponents.Import "h:\Macros\PSSupport.bas"
..VBProject.VBComponents.Import "h:\Macros\PSLogin.frm"
..VBProject.References.AddFromFile
"C:\WINDOWS\system32\vbscript.dll\3"
..VBProject.References.AddFromFile
"C:\WINDOWS\system32\shdocvw.dll"

..SaveAs "H:\EXCEL\FollowUpList.xls", xlWorkbookNormal
End With
End Sub
 
Another option would be just to leave the code in its own workbook.

Then have that "macro workbook" open whenever you need to run the macro.

(I've found that it's easier to make a change in one workbook, than to find all
the workbooks and update all those.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top