Call A Custom Dialog Box From A Procedure

You can call and display any custom dialog boxes that are part of the same project as your procedure. You use custom dialog boxes to gather user input. For example, you can use the dialog box to request the values you need from the user to perform the appropriate calculations within a worksheet.

To display a custom dialog box, you use the Show method of the UserForm object. The Show method instructs Excel to display the specified UserForm. The Show method has only one optional parameter, as shown in the following code:

UserFormi.Show modal.

The modal parameter determines whether the specified UserForm displays as a modal or modeless dialog box within Excel. The default value of vbModal makes the dialog box modal, which means that you must either close or hide the dialog box before selecting any other options within Excel. When Excel opens a modal dialog box, all control is passed to that dialog box and you can only select options on the dialog box. A value of vbModeless means that although the dialog box remains open until a user closes it, a user can perform other program options.

You can close a dialog box in Excel via the Close button in the upper-right corner of the dialog box. You can also close it within your macro when you use the Unload method. Typically, all dialog boxes can contain a Close or Cancel button, which enables a user to close the dialog box. You must use the Click event for these CommandButton controls to create a procedure that calls the Unload method. See "Capture Input from a Custom Dialog Box" for more information about specifying code to run when a user clicks a button.

CALL A CUSTOM DIALOG BOX FROM A PROCEDURE

CALL A CUSTOM DIALOG BOX FROM A PROCEDURE

—n Create a UserForm within the appropriate project.

Note: See the section "Create a Custom Dialog Box" for information on creating UserForms.

—0 Create a new subroutine.

Note: See Chapter 3 for information on creating subroutines.

—n Create a UserForm within the appropriate project.

Note: See the section "Create a Custom Dialog Box" for information on creating UserForms.

—0 Create a new subroutine.

Note: See Chapter 3 for information on creating subroutines.

0 0

Responses

Post a comment