Home |
Search |
Today's Posts |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
That is by design. The help file states that you have to use the
RunAutoMacros, like this: xlapp.ActiveWorkbook.RunAutoMacros 1 'xlAutoOpen from the help file: Runs the Auto_Open, Auto_Close, Auto_Activate, or Auto_Deactivate macro attached to the workbook. This method is included for backward compatibility. For new Visual Basic code, you should use the Open, Close, Activate and Deactivate events instead of these macros. expression.RunAutoMacros(Which) expression Required. An expression that returns one of the objects in the Applies To list. Which Required XlRunAutoMacro. XlRunAutoMacro can be one of these XlRunAutoMacro constants. xlAutoActivate. Auto_Activate macros xlAutoClose. Auto_Close macros xlAutoDeactivate. Auto_Deactivate macros xlAutoOpen. Auto_Open macros Example This example opens the workbook Analysis.xls and then runs its Auto_Open macro. Workbooks.Open "ANALYSIS.XLS" ActiveWorkbook.RunAutoMacros xlAutoOpen This example runs the Auto_Close macro for the active workbook and then closes the workbook. With ActiveWorkbook .RunAutoMacros xlAutoClose .Close End With -- Regards, Juan Pablo González Excel MVP "CRayF" wrote in message ... I've created an example.VBS file that contains: ----------------- Dim XLApp Set XLApp = CreateObject("Excel.Application") xlapp.visible = true xlapp.workbooks.open "myworkbook.xls" ----------------- In the myworkbook.xls is an auto run macro ------------- Sub Auto_Open() 'some code End Sub ------------- If I start the myworkbook.xls by itself it runs the Auto_Open() macro *just fine*. However, when my myworkbook.xls is called via the example.VBS script it DOES NOT auto run the macro. Any clues? |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How to get Started with macro? | Excel Discussion (Misc queries) | |||
Auto_Open Macro | Excel Discussion (Misc queries) | |||
auto_open macro not performing as expected | Excel Programming | |||
Help with SaveAs Macro on Auto_Open | Excel Programming | |||
Auto_Open vs. macro | Excel Programming |