The Display and Execute Methods

The Display method has syntax:

	DialogBox.Display(TimeOut)

and differs from the Show method in only one way: after the dialog box is dismissed, no actions are taken. This method is used to prompt the user with a dialog box.

Note that if the user makes any changes in a dialog box while it is displayed, these changes will not be applied unless we use the Execute method. For instance, the following code displays the Font formatting dialog box. Once the user has dismissed the dialog, it checks to see if the font was changed to Tahoma. If so, it asks the user if she is sure and then either makes the change or discards it:

	Dim dial As Dialog
	Set dial = Dialogs(wdDialogFormatFont)
	dial.Display
	If dial.Font = "Tahoma" Then
	   If MsgBox("You have selected Tahoma. Are you sure?", _
	      vbYesNo) = vbYes Then
	      dial.Execute
	   End If
	Else
	   dial.Execute
	End If

Get Writing Word Macros, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.