DocumentBase.RunAutoMacro Method (WdAutoMacros)

 

Runs an auto macro that is stored in the document.

Namespace:   Microsoft.Office.Tools.Word
Assembly:  Microsoft.Office.Tools.Word.v4.0.Utilities (in Microsoft.Office.Tools.Word.v4.0.Utilities.dll)

public void RunAutoMacro(
	WdAutoMacros which
)

Parameters

which
Type: Microsoft.Office.Interop.Word.WdAutoMacros

One of the WdAutoMacros values.

If the specified auto macro does not exist, nothing happens.

The following code example uses the RunAutoMacro method to run the AutoOpen auto macro. This example assumes that the AutoOpen macro has been added to the document. To use this example, run it from the ThisDocument class in a document-level project.

private void DocumentRunAutoMacro()
{
    this.RunAutoMacro(Word.WdAutoMacros.wdAutoOpen);
}
Return to top
Show: