Class Dialog (Word VBA)
The class Dialog represents a built-in dialog box. The Dialog object is a member of the Dialogs collection. The Dialogs collection contains all the built-in dialog boxes in Word. You cannot create a new built-in dialog box or add one to the Dialogs collection. To use a Dialog class variable it first needs to be instantiated, for example
Dim dlg as Dialog
Set dlg = Dialogs(Index:=1)
For Each
Here is an example of processing the Dialog items in a collection.
Dim dlg As Dialog
For Each dlg In Dialogs
Next dlg
CommandBarId
Returns a Long that represents the toolbar control id for a built-in Microsoft Word dialog box.
Dim lngCommandBarId As Long
lngCommandBarId = Dialogs(1).CommandBarId
CommandName
Returns the name of the procedure that displays the specified built-in dialog box.
For more information about working with built-in Word dialog boxes, see Displaying Built-in Word Dialog Boxes.
MsgBox Dialogs(wdDialogFileSaveAs).CommandName
DefaultTab
Returns or sets the active tab when the specified dialog box is displayed. Here you can find possible values for
With Dialogs(wdDialogFilePageSetup)
.DefaultTab = wdDialogFilePageSetupTabPaperSource
.Show
End With
Display
Displays the specified built-in Word dialog box until either the user closes it or the specified amount of time has passed. Returns a Long that indicates which button was clicked to close the dialog box.
The Display method returns the following possible values.
Display (TimeOut)
TimeOut: The amount of time that Word will wait before closing the dialog box automatically. One unit is approximately 0.001 second. Concurrent system activity may increase the effective time value. If this argument is omitted, the dialog box is closed when the user closes it.
Dim dlgAbout As Dialog
Set dlgAbout = Dialogs(wdDialogHelpAbout)
dlgAbout.Display TimeOut:=10000
Execute
Applies the current settings of a Microsoft Word dialog box.
With Dialogs(wdDialogFormatParagraph)
.KeepWithNext = 1
.Execute
End With
Show
Displays and carries out actions initiated in the specified built-in Word dialog box. Returns a Long that indicates which button was clicked to close the dialog box.
The following table shows the meaning of the values that the Show method returns.
Show (TimeOut)
TimeOut: The amount of time that Word will wait before closing the dialog box automatically. One unit is approximately 0.001 second. Concurrent system activity may increase the effective time value. If this argument is omitted, the dialog box is closed when the user dismisses it.
With Dialogs(wdDialogEditFind)
.Find = "Blue"
.Show
End With
Type
Returns the type of built-in Microsoft Word dialog box. Here you can find possible values for
Dim wwdType As WdWordDialog
wwdType = Dialogs(1).Type
Update
Updates the values shown in a built-in Microsoft Word dialog box.
Set myDialog = Dialogs(wdDialogFormatFont)
Selection.Font.Name = "Arial"
myDialog.Update
myDialog.Show