|Excel Developer Reference|
expression A variable that represents an Application object.
|XlEnableCancelKey can be one of these XlEnableCancelKey constants.|
|xlDisabled. Cancel key trapping is completely disabled.|
|xlErrorHandler. The interrupt is sent to the running procedure as an error, trappable by an error handler set up with an |
|xlInterrupt. The current procedure is interrupted, and the user can debug or end the procedure.|
Use this property very carefully. If you use xlDisabled, there's no way to interrupt a runaway loop or other non – self-terminating code. Likewise, if you use xlErrorHandler but your error handler always returns using the
Resume statement, there's no way to stop runaway code.
The EnableCancelKey property is always reset to xlInterrupt whenever Microsoft Excel returns to the idle state and there's no code running. To trap or disable cancellation in your procedure, you must explicitly change the EnableCancelKey property every time the procedure is called.
This example shows how you can use the EnableCancelKey property to set up a custom cancellation handler.
|Visual Basic for Applications|