Word uses a second method, .Display, that enables the user to make a selection from a dia-
log box but doesn’t actually complete the normal operation of the dialog box. For example,
you can use the
.Displaymethod with the Open dialog box to retrieve a filename; when the
user selects a file and clicks Open, your program can use the specified filename without
opening the file itself.
With Dialogs(wdDialogFileOpen)
.Name = “*.htm”
.Display
MsgBox “You chose File “ & .Name
End With
43
NOTE
The
With/End Withcommand pair saves you a lot of typing. When you add a parame-
ter after the
Withcommand, VBA tacks ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month, and much more.