Syntax

expression.RunAutoMacros(Which)

expression A variable that represents a Workbook object.

Parameters

Name Required/Optional Data Type Description
Which Required Specifies the automatic macro to run.

Remarks

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.

Visual Basic for Applications
Workbooks.Open "ANALYSIS.XLS" ActiveWorkbook.RunAutoMacros xlAutoOpen

This example runs the Auto_Close macro for the active workbook and then closes the workbook.

Visual Basic for Applications
With ActiveWorkbook .RunAutoMacros xlAutoClose .Close End With
run run auto macros runauto RunAutoMacros RunAutoMacros method

See also: