Error Handling Ctrl-Break While MsgBox Shown

Microsoft Excel 95 does not produce a run-time error when a message box is showing and Ctrl-Break is executed (it simply dismisses the box and continues). Because Microsoft Excel 97 will generate a run-time error in this case, you may want to add error handling around your message boxes, or at least be aware that your existing error handling will be called. When doing so, note that under Microsoft Excel 97 there is a difference between Resume and Resume Next. Whereas Resume Next will skip two lines following the line that caused the error, Resume will simply continue. Consider the following example:

Sub Excel97MsgBoxExample()
     On Error Goto ERRORHANDLER
     Application.EnableCancelKey = xlErrorHandler
     MsgBox "First"
     MsgBox "Second"    'This line gets skipped if Resume Next used
     MsgBox "Third"
     Exit Sub
ERRORHANDLER:
     MsgBox "Escape Key Hit"
     Resume             'Using Resume here ensures that no lines skipped
End Sub

Remember that the condition we are describing here does not apply to dialog boxes or UserForms.