Hi all,
I'm trying to trap error 18 which releates to Code Interrupt when a user presses ESC or CTRL+BREAK (see below). However, when I press ESC the code just stops and when pressing CTRL+BREAK the in-built error message appears rather than the msgbox (see below).
Any ideas why this is?
Thanks,
Paul.
On Error GoTo MYERROR
Application.EnableCancelKey = xlErrorHandler
''''
''''' Code stuff
''''
Exit Sub
MYERROR:
Select Case Err.Number
Case 18
MsgBox "The program has been interrupted and will now terminate.", vbCritical, "Program Halted"
Case Else
MsgBox "The following error has occurred:" & vbCrLf & vbCrLf & Err.Number & vbCrLf & Err.Description, vbOKOnly, "Program Error"
End Select
I'm trying to trap error 18 which releates to Code Interrupt when a user presses ESC or CTRL+BREAK (see below). However, when I press ESC the code just stops and when pressing CTRL+BREAK the in-built error message appears rather than the msgbox (see below).
Any ideas why this is?
Thanks,
Paul.
On Error GoTo MYERROR
Application.EnableCancelKey = xlErrorHandler
''''
''''' Code stuff
''''
Exit Sub
MYERROR:
Select Case Err.Number
Case 18
MsgBox "The program has been interrupted and will now terminate.", vbCritical, "Program Halted"
Case Else
MsgBox "The following error has occurred:" & vbCrLf & vbCrLf & Err.Number & vbCrLf & Err.Description, vbOKOnly, "Program Error"
End Select