Skip to content

Latest commit

 

History

History
53 lines (34 loc) · 1.32 KB

Excel.Workbook.RunAutoMacros.md

File metadata and controls

53 lines (34 loc) · 1.32 KB
title keywords f1_keywords api_name ms.assetid ms.date ms.localizationpriority
Workbook.RunAutoMacros method (Excel)
vbaxl10.chm199143
vbaxl10.chm199143
Excel.Workbook.RunAutoMacros
85dfdadf-75e6-437d-fb7a-e17681a69b35
05/29/2019
medium

Workbook.RunAutoMacros method (Excel)

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, Activate, and Deactivate events and the Close method instead of these macros.

Syntax

expression.RunAutoMacros (Which)

expression A variable that represents a Workbook object.

Parameters

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

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

[!includeSupport and feedback]