Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default How do I copy macro into new workbook that was created automatica.

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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default How do I copy macro into new workbook that was created automatica.

Look at Chip Pearson's page on working with the VBE with code
http://www.cpearson.com/excel/vbe.htm

--
Regards,
Tom Ogilvy

"Darshan" wrote in message
...
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.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default How do I copy macro into new workbook that was created automatica.

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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default How do I copy macro into new workbook that was created automatica.

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
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
copy 2007 created macro to run in 2003 amaries Excel Discussion (Misc queries) 4 December 18th 08 07:48 PM
I want to copy rows with values 0 to another worksheet automatica Skeletor Excel Worksheet Functions 4 September 24th 08 11:47 PM
Macro Created but Not Running in Workbook alexaed Excel Worksheet Functions 9 August 14th 07 08:48 PM
Macro run each time a new workbook created cmorton89 Excel Discussion (Misc queries) 0 March 8th 06 07:58 PM
Runtime error for macro that works in workbook created in Crystal Excel Discussion (Misc queries) 1 June 22nd 05 08:43 PM


All times are GMT +1. The time now is 05:32 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"