EnableCancelKey Property

Microsoft Word Visual Basic

Returns or sets the way that Word handles CTRL+BREAK user interruptions. Read/write WdEnableCancelKey.

WdEnableCancelKey can be one of these WdEnableCancelKey constants.
wdCancelDisabled Prevents CTRL+BREAK from interrupting a macro.
wdCancelInterrupt Allows a macro to be interrupted by CTRL+BREAK.

expression.EnableCancelKey

expression    Required. An expression that returns one of the objects in the Applies To list.

Remarks

Use this property very carefully. If you use wdCancelDisabled, there's no way to interrupt a runaway loop or other non – self-terminating code. Also, the EnableCancelKey property is not reset to wdCancelInterrupt when your code stops running; unless you explicitly reset its value, it will remain set to wdCancelDisabled for the duration of the Word session.

Example

This example disables CTRL+BREAK from interrupting a counter loop.

Dim intWait As Integer

Application.EnableCancelKey = wdCancelDisabled
For intWait = 1 To 10000
    StatusBar = intWait
Next intWait
Application.EnableCancelKey = wdCancelInterrupt