Share via


Displaying a Custom Dialog Box

To test your dialog box in the Visual Basic Editor, click Run Sub/UserForm on the Run menu.

To display a dialog box from Visual Basic, use the Show method. The following example displays the dialog box named UserForm1.

  Private Sub GetUserName()
    UserForm1.Show
End Sub

Note  Use the Unload method in an event procedure, such as the Click event procedure for a command button, to close a dialog box.

See Also | Adding Controls to a Document | Adding Controls to a UserForm | Creating a Custom Dialog Box | Creating a UserForm | Initializing Control Properties | Setting Control Properties | Using ActiveX Controls on a Document | Using ActiveX Controls on Word Documents | Using Control Values While Code is Running