O'Reilly logo

Writing Word Macros, Second Edition by Steven Roman PhD

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required