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.
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.
Look at Chip Pearson's page on working with the VBE with code
http://www.cpearson.com/excel/vbe.htm
--
Regards,
Tom Ogilvy
"Darshan" <Darshan@discussions.microsoft.com> wrote in message
news:AF1B8F44-FEB5-41F4-BF8C-6E64E4DE4BC0@microsoft.com...
> 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.)
Darshan wrote:
>
> 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.
--
Dave Peterson
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks