Article ID: 162939
Article Last Modified on 1/19/2007
Sub Main()
Dim dlg As Object
Set dlg = WordBasic.DialogRecord.FormatHeadingNumbering(False)
WordBasic.CurValues.FormatHeadingNumbering dlg
x = WordBasic.Dialog.FormatHeadingNumbering(dlg)
' In WordBasic, if the Cancel button was pressed, x will equal zero.
If x = 0 Then
' Because Visual Basic for Applications WordBasic object returns
' -1 for Cancel, any commands in this If...Then...Else statement
' will be skipped when Cancel is clicked.
MsgBox "Cancel was pressed."
End If
End Sub
Sub Main()
Dim dlg As Object
Set dlg = WordBasic.DialogRecord.FormatHeadingNumbering(False)
WordBasic.CurValues.FormatHeadingNumbering dlg
x = WordBasic.Dialog.FormatHeadingNumbering(dlg)
' If the Cancel button was pressed, x will equal -1.
If x = -1 Then
' Perform actions based on the Cancel button being clicked.
End If
End Sub
NOTE: Using Visual Basic for Applications commands without the WordBasic
object returns zero for a Cancel button. For example, the following
procedure performs the same functionality as the converted WordBasic macro
examples described earlier in this article:
Sub ShowDlg()
' Display the Bullets and Numbering Dialog.
With Dialogs(wdDialogFormatBulletsAndNumbering)
.DefaultTab = wdDialogFormatBulletsAndNumberingTabOutlineNumbered
x = .Show
End With
' If x=zero then the Cancel button was clicked.
If x = 0 Then
MsgBox "Cancel was pressed."
End If
End Sub
173707 OFF97: 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: kbbug kbmacroexample kbnofix KB162939