Skip to content

Latest commit

 

History

History
58 lines (37 loc) · 1.34 KB

Project.Application.EnableCancelKey.md

File metadata and controls

58 lines (37 loc) · 1.34 KB
title keywords f1_keywords ms.service api_name ms.assetid ms.date ms.localizationpriority
Application.EnableCancelKey property (Project)
vbapj.chm131792
vbapj.chm131792
project-server
Project.Application.EnableCancelKey
9b5f4f90-3ef3-139b-5f76-f48d3d7710a8
06/08/2017
medium

Application.EnableCancelKey property (Project)

Gets or sets a value that controls how the CTRL + BREAK key combination is handled when a macro is running. Read/write PjEnableCancelKey.

Syntax

expression. EnableCancelKey

expression A variable that represents an Application object.

Remarks

The EnableCancelKey property can be one of the following PjEnableCancelKey constants: pjDisabled, pjErrorHandler, or pjInterrupt.

Example

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]