RunAutoMacro Method

Microsoft Word Visual Basic

Show All Show All

RunAutoMacro Method

Runs an auto macro that's stored in the specified document. If the specified auto macro doesn't exist, nothing happens.

Note  Use the Run method to run any macro.

expression.RunAutoMacro(Which)

expression    Required. An expression that returns one of the objects in the Applies To list.

Which   Required WdAutoMacros.

WdAutoMacros can be one of these WdAutoMacros constants.
wdAutoExec
wdAutoNew
wdAutoClose
wdAutoExit
wdAutoOpen
wdAutoSync

Example

This example runs the AutoOpen macro in the active document.

    ActiveDocument.RunAutoMacro Which:=wdAutoOpen