EnableCancelKey Property

Applies To

Application object.

Description

Returns or sets the way that Word handles CTRL+BREAK user interruptions. Can be either one of the following WdEnableCancelKey constants: wdCancelDisabled (prevents CTRL+BREAK from interrupting a macro) or wdCancelInterrupt (allows a macro to be interrupted by CTRL+BREAK). Read/write Long.

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. The EnableCancelKey property is reset to wdCancelInterrupt when your code stops running.

Example

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

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