1172
Chapter 43 Building Custom Applications with VBA
3. VBA provides the first and last lines of the new subroutine. You add the middle one:
Public Sub WarningMessage()
MsgBox “Your Message Here”
End Sub
4. To run the WarningMessage macro, click the Run Sub/User Form button (or press F5).
The message box appears. Click OK in the message box and the macro finishes.
Displaying Messages in Word with VBA
A more complex message box includes the message text, a title, and a description of the but-
tons that should appear. For example, let’s assume you want to create a message that asks,
“Do you want to print the current document?” with buttons for Yes and No. ...