MrExcel Publishing
Your One Stop for Excel Tips & Solutions

To automatically launch a macro when a file is opened.


Posted by Mark Gravelle on November 09, 2001 4:30 PM

Is there a way I can open a file and the macro automatically launches itself?

LUKE>>>thanks for the other advice on combo box. Although I'm still having trouble...I'm working on it. (Because I'm very new to VBA so it's taking a bit to understand).


Posted by Tom Urtis on November 09, 2001 6:01 PM

Yes there is, just write the code and place the macro in a procedure called Sub Auto_Open, or in the Workbook module as a Workbook_Open event. Right click on the Excel logo to the left og the File option on the worksheet menu bar, and select View Code. Example:
Private Sub Workbook_Open()
MsgBox "Welcome to my file."
End Sub

Of course, replace the MsgBox line with your code.

HTH

Tom Urtis

Posted by Mark Gravelle on November 10, 2001 11:50 AM