DocumentBase.RunAutoMacro Method
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)
Syntax
'Declaration
Public Sub RunAutoMacro ( _
which As WdAutoMacros _
)
public void RunAutoMacro(
WdAutoMacros which
)
Parameters
which
Type: Microsoft.Office.Interop.Word.WdAutoMacrosOne of the WdAutoMacros values.
Remarks
If the specified auto macro does not exist, nothing happens.
Examples
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 Sub DocumentRunAutoMacro()
Me.RunAutoMacro(Word.WdAutoMacros.wdAutoOpen)
End Sub
private void DocumentRunAutoMacro()
{
this.RunAutoMacro(Word.WdAutoMacros.wdAutoOpen);
}
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.