![]() |
autorun macro
I want to have a macro run each time I open a new excel file based upon
a specific template. I saved the macro in the ThisWorkbook module of the template, but still the macro has to be manually run for each new file. Is there a way for new files to autorun the macro in their ThisWorkbook module? ------------------------------------------------ ~~ Message posted from http://www.ExcelTip.com/ ~~ View and post usenet messages directly from http://www.ExcelForum.com/ |
autorun macro
"hke" wrote in message ... I want to have a macro run each time I open a new excel file based upon a specific template. I saved the macro in the ThisWorkbook module of the template, but still the macro has to be manually run for each new file. Is there a way for new files to autorun the macro in their ThisWorkbook module? Is the macro called Workbook_Open() ? GB |
autorun macro
Yes it is
------------------------------------------------ ~~ Message posted from http://www.ExcelTip.com/ ~~ View and post usenet messages directly from http://www.ExcelForum.com/ |
autorun macro
"hke" wrote in message ... Yes it is ------------------------------------------------ ~~ Message posted from http://www.ExcelTip.com/ ~~ View and post usenet messages directly from http://www.ExcelForum.com/ Hmm - I asked because I have the following code in a test template: Private Sub Workbook_Open() MsgBox "hi" End Sub It's in the workbook code. It works 100% - every time! So, what are you doing that's different? GB |
autorun macro
Mine is also in the workbook code.
The macro puts the path of the file in the title area. I guess its like this: The file needs to be saved to set the path and therefore nothing happens at opening since the file has not been saved. It would be preferable to have the macro run automatically after save ------------------------------------------------ ~~ Message posted from http://www.ExcelTip.com/ ~~ View and post usenet messages directly from http://www.ExcelForum.com/ |
autorun macro
"hke" wrote in message ... Mine is also in the workbook code. The macro puts the path of the file in the title area. I guess its like this: The file needs to be saved to set the path and therefore nothing happens at opening since the file has not been saved. It would be preferable to have the macro run automatically after save Can you not save immediately after open? GB |
autorun macro
Put the macro in a general module with a different name such as AddPath
In the BeforeSave event in the workbook module put in code like Application.Ontime Now + TimeValue("00:00:05"),"AddPath" -- Regards, Tom Ogilvy "hke" wrote in message ... Mine is also in the workbook code. The macro puts the path of the file in the title area. I guess its like this: The file needs to be saved to set the path and therefore nothing happens at opening since the file has not been saved. It would be preferable to have the macro run automatically after save ------------------------------------------------ ~~ Message posted from http://www.ExcelTip.com/ ~~ View and post usenet messages directly from http://www.ExcelForum.com/ |
All times are GMT +1. The time now is 11:14 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com