Copying a macro to multiple docs

Closed
Kat - Feb 26, 2010 at 03:23 PM
rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 - Feb 26, 2010 at 03:48 PM
Hello,

Is there a way to copy a macro into multiple excel files at the same time without touching each file? I have a macro built and need to incorporate into 400 files, I can copy from doc to doc with opening each, but would like to copy to over 400 without opening each file.

Thanks!

1 response

rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 766
Feb 26, 2010 at 03:48 PM
You can have macro save in an xla file. So each time excel opens, macro is available

or in a new book have some thing like this

Sub AddModule(myBook As Workbook, myModule As String)

myBook.VBProject.VBComponents.Import myModule

End Sub

and define your book and module to import
0