DismissButton Property

Applies To

Button Object, Buttons Collection, DrawingObjects Collection.

Description

True if the button will automatically close a user-defined dialog box when the button is clicked. Any number of buttons on a dialog sheet can have the DismissButton property set to True. Read-write.

Remarks

When you click a button that has the DismissButton property set to True, three steps are taken:

1. The button's OnAction procedure runs. If you want to do any custom data validation, do it in this procedure. If validation fails, you can set the DismissButton property to False, in which case the dialog box remains visible. Remember to reset the DismissButton property to True when validation passes.

2. When the OnAction procedure ends, edit boxes in the dialog box are automatically validated to ensure that they contain data of the type specified by their InputType properties. If automatic validation fails, Microsoft Excel displays an alert, the offending edit box gets the focus, and the dialog box remains visible.

3. If automatic validation passes, the dialog box closes and the Show method that called the dialog sheet returns True.

If no button in the dialog box has the DismissButton property set to True, then you must explicitly call the Hide method or cancel the dialog box to close it.

See Also

CancelButton Property, Hide Method, InputType Property, OnAction Property, Show Method.

Example

This example sets the DismissButton property for every button on Dialog1.


For Each bt in DialogSheets("Dialog1").Buttons
    bt.DismissButton = True
Next bt