Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 70
Default 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




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default autorun macro

Yes it is



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 70
Default 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


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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/



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 70
Default 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


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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/



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
Autorun macro Josh Excel Discussion (Misc queries) 2 August 16th 09 02:19 PM
AutoRun Macro chrisnsmith Excel Worksheet Functions 5 February 4th 09 07:25 PM
autorun a macro [email protected] New Users to Excel 2 January 24th 08 05:41 PM
Autorun Macro rexmann Excel Discussion (Misc queries) 2 August 2nd 06 02:03 PM
MACRO AUTORUN b52shut Excel Discussion (Misc queries) 1 December 15th 05 08:48 AM


All times are GMT +1. The time now is 09:01 AM.

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"