Archive of Mr Excel Message Board

Back to Excel VBA archive index
Back to archive home

Auto start of macro on file open
Posted by John on November 23, 2001 9:35 AM
How do I get a macro to run when a file is opened. I know there is a way but I can't remember where to put the macro to start up when the file is first openened.
Thanks in advance for all of your help.
John

| Check out our Excel VBA Resources
|
 |
 |
 |
 |
 |
Re: Auto start of macro on file open
Posted by Stan on November 23, 2001 10:17 AM
John
Call your macro from Sub Workbook_Open (). Go to Tools > Macro > Visual Basic Editor and under "Microsoft Excel Objects" click on ThisWorkBook. Then use:
Sub WorkBook_Open ()
Call MyMacro
End Sub
How do I get a macro to run when a file is opened. I know there is a way but I can't remember where to put the macro to start up when the file is first openened.

Re: Auto start of macro on file open
Posted by Gary Hewitt-Long on November 23, 2001 10:18 AM
Open the visual basic editor and place the macro in ThisWorkbook not in a module.
Place the macro within:
Private Sub Workbook_Open()
End Sub
Or within those lines put:
Application.Run.("Personal.XLS!My_Macro")
Regards,
Gary Hewitt-Long

Re: Auto start of macro on file open
Posted by Lieuwer on November 25, 2001 9:19 PM
In a normal module you can create a macro with the name " Auto_open() ". This macro will run when you open the file.
PS. The macro " Auto_close() " will do the same each time you close your file.
Good luck.
Lieuwer

This archive is from the original message board at www.MrExcel.com.
All contents © 1998-2004 MrExcel.com.
Visit our
online store to buy searchable CD's with thousands of VBA and Excel answers.
Microsoft Excel is a registered trademark of the Microsoft Corporation.
MrExcel is a registered trademark of Tickling Keys, Inc.