Display A Builtin Dialog

You can display all of the dialog boxes available in Excel in your macros by using VBA. By displaying a particular dialog box, you can incorporate that Excel functionality directly into your procedure. The Excel Object Model contains a Dialog object for each of the Excel dialog boxes. These objects are part of the Dialogs collection.

You can access each of the Excel dialog box objects by specifying the corresponding constant value. The constant value for each dialog box begins with xlDialog followed by the name for the dialog. For example, the constant for the Excel Save As dialog box is xlDialogSaveAs.

You can use the Show method only when working with the Dialogs collection. This method essentially displays the dialog box that you specified.

DISPLAY A BUILT-IN DIALOG BOX

Although you can open a specific dialog box, you cannot access the values that a user specifies on the dialog box. You can only determine what the user selects by looking at the results after the user dismisses the dialog box. You can, however, use the arguments available with the dialog box to indicate how the dialog box opens. For example, the Properties dialog box (xlDialogProperties) has the following arguments: title, subject, author, keywords, and comments. You can specify custom values for these arguments when you open the dialog box.

Excel provides more than 200 different dialog boxes, and the Excel Object Model provides a constant value to access each one. You can find a complete list of the dialog box constants in the online help that comes with the Visual Basic Editor. Another good method for viewing the dialog box constants is using the Object Browser and searching for the XlBuiltinDialog constants. See the section "Using the Object Browser" for more information.

DISPLAY A BUILT-IN DIALOG BOX

LQ Type Sub Open_DialogBox(). ■ The End Sub statement

Press Enter.

—0 Type Application.Dialogs (xlDialogProperties), replacing xlDialogProperties with the constant for the desired dialog box.
0 0

Responses

Post a comment