Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel macros

Status
Not open for further replies.

scrappe7

Technical User
Jul 30, 2001
82
0
0
US
Any way to autostart a macro on the open or close of that xls file??? If yes what does it look like, thanks.
 
set your worksheet to it's own window (the one between minimize and exit) then right click in the bar at the top of the column letters then choose view code, in the left drop down, change (general) to "workbook" and in the next drop down choose "open"

Place your code or, a sub/function name (to call),here.
 
With your workbook open, hit Alt+F11 to open the VB editor
Ctrl+R will display the project explorer - in that, expand the 'Microsoft Excel Objects' folder in the project for your file [VBAProject(yourfilename)] and double-click 'This Workbook'
This should bring up the code window for the workbook_open event
Calling your marco from here will run it every time you open that workbook:

Private Sub Workbook_Open()
Call myMacro
End Sub

Note: The right combo box above the code window lists the other workbook events that you might want to use as well

Enjoy :)
Killian
 
Great minds think alike... but may type at different speeds

K ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top