Article ID: 183147
Article Last Modified on 6/17/2005
-or-
Sub DoesMacroExist()
On Error Resume Next
' Use the Macro Dialog to run macro.
With Dialogs(wdDialogToolsMacro)
.Name = "xcallmacro"
' Attempt to run the macro.
.Run = True
.Execute
' If macro does not exist, an error will occur.
If Err = 4633 Or Err = 4649 Then
MsgBox "Macro not found."
ElseIf Err = 0 Then
MsgBox "Macro found."
Else
Err.Description
End If
End With
End Sub
For additional information, please see the following article in the
Microsoft Knowledge Base:
181058 OFF98: How to Run Sample Code from Knowledge Base Articles
163435 VBA: Programming Resources for Visual Basic for Applications
Additional query words: wordcon vb vba vbe
Keywords: kbhowto kbmacroexample kbdtacode KB183147