No, not any macro followed by _Open. It HAS to be "Private Sub Workbook_Open().
Try it, and you'll see that it works. Implicitly, you will need to include your code within this routine - i.e. after "Private Sub Workbook_Open()" and before "End Sub".
Actually, if you go to the VBE (Visual Basic Editor, Alt+F11), double click on the This WorkBook in the left hand pane, and select workbook from the drop don list towards the top. Type your code in there.
Also, be VERY careful what you put in there. JV had a spreadsheet where someone had typed:
Code:
Private Sub Workbook_Open()
Application.Quit
End Sub
(I Think. Never could open the %$^%^* thing) Tyrone Lumley
augerinn@gte.net
Thanks Ty, for contributing. You are indeed right about the need to select "ThisWorkbook". I had too many interruptions today, and didn't focus long enough to cover the entire picture.
Sorry, Paul, for not getting it right the first time.
By the way, Ty, can you also share the method of creating an "On Close" routine. I have yet to create an Excel application which requires this, but it is nonetheless something I would like to know for the future. I have tried Workbook_Close, but it doesn't work. Can you help ?
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.