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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run Auto_open macros in excel 97

Status
Not open for further replies.

ricky9151

Programmer
Jun 23, 2004
1
US
HI
I have a winbatch script that is executing a report but I need it to execute the auto_open macro automatically on opening the workbook. I put the following code in the Workbook event Open but it did not work. THis server is still using Excel 97. Any ideas??

Workbook_Open()
Dim XLFlash as Excel.workbook
Activeworkbook.RunAutoMacros (xlAutoOpen)
Set XLFlash = nothing
End Sub

Lana
 
Lana,
Code:
Private Sub Workbook_Open()
  YourMacro
End Sub
That's all it takes! ;-)

Skip,

Want to get great answers to your Tek-Tips questions? Have a look at faq222-2244
 
Lana,
The Workbook_Open sub doesn't run when the workbook is opened programmatically. You need to trigger it in a separate statement. Here's the example from Microsoft on-line help (for a workbook named "ANALYSIS.XLS"

Code:
Workbooks.Open "ANALYSIS.XLS"
ActiveWorkbook.RunAutoMacros xlAutoOpen
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top