title | keywords | f1_keywords | ms.service | api_name | ms.assetid | ms.date | ms.localizationpriority | ||
---|---|---|---|---|---|---|---|---|---|
Application.EnableCancelKey property (Project) |
vbapj.chm131792 |
|
project-server |
|
9b5f4f90-3ef3-139b-5f76-f48d3d7710a8 |
06/08/2017 |
medium |
Gets or sets a value that controls how the CTRL + BREAK key combination is handled when a macro is running. Read/write PjEnableCancelKey.
expression. EnableCancelKey
expression A variable that represents an Application object.
The EnableCancelKey property can be one of the following PjEnableCancelKey constants: pjDisabled, pjErrorHandler, or pjInterrupt.
The following example shows how you can use the EnableCancelKey property to create a custom cancellation error handler.
Sub CancelOperation()
Dim X As Long
On Error GoTo handleCancel
Application.EnableCancelKey = pjErrorHandler
MsgBox "This may take a long time; press CTRL+BREAK to cancel."
For X = 1 To 300000000
' Do something here.
Next X
handleCancel:
If Err = 18 Then
MsgBox "Operation cancelled"
End If
End Sub
[!includeSupport and feedback]