Applies To
Button Object, Buttons Collection, DrawingObjects Collection.
Description
Applies only to buttons in a user-defined dialog box. True if the button is automatically selected when the ESCAPE key is pressed or when the system menu close box or menu item is selected. When the user presses the ESCAPE key, the Cancel button is selected, and Microsoft Excel runs the macro identified by the button's OnAction property.
Remarks
Set this property for a button if you want some code to always run when the dialog box is canceled, even if it is canceled by the ESCAPE key or the system menu.
Only one button in the dialog box can have the CancelButton property set to True at any given time. Setting one will reset this property for all other buttons on the dialog sheet.
See Also
DismissButton Property.
Example
This example sets the CancelButton property for button one on Dialog1.
DialogSheets("Dialog1").Buttons(1).CancelButton = True