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


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.


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




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