Hi all,
I've had a search around and found variations of this question across the web, but none answered.
My understanding is that that escape key should immediately stop a macro, raising error code 18 and have previously found this to be the case.
I'm now using a different computer (Windows 8, Excel 2013) and it doesn't behave the same way.
Example:
Pressing Esc while the status bar says "Waiting 1" should end the macro with an error, the status bar should stay the same and I should have the opportunity to enter debug mode.
When I do this the status bar instead immediately changes to "Done waiting", no error, no message box.
Example 2:
Pressing escape during Waiting 1 on this changes the status bar immediately to Waiting 2, then 10 seconds later to Done waiting. No errors or message boxes.
Running both without pressing escape runs as expected with waits and the message box popping up.
Ctrl+Break works correctly in both of these cases, but as I don't currently have a keyboard with a break key, it's a pain using the on-screen keyboard to abort auto-running macros quickly.
Escape also does not trigger the error handler when using Application.EnableCancelKey = xlErrorHandler
It looks like escape is causing vba to skip certain commands (waits), run others (status bar updates), and be interrupted by some others (message box).
Any ideas on what's going on?
Could there be a setting that has been changed on this computer?
I've had a search around and found variations of this question across the web, but none answered.
My understanding is that that escape key should immediately stop a macro, raising error code 18 and have previously found this to be the case.
I'm now using a different computer (Windows 8, Excel 2013) and it doesn't behave the same way.
Example:
Code:
Sub main()
Application.StatusBar = "Waiting 1"
Application.Wait (Now + TimeValue("00:00:10"))
Application.StatusBar = "Waiting 2"
Application.Wait (Now + TimeValue("00:00:10"))
Application.StatusBar = "Done waiting"
MsgBox ("Message Box")
End Sub
Pressing Esc while the status bar says "Waiting 1" should end the macro with an error, the status bar should stay the same and I should have the opportunity to enter debug mode.
When I do this the status bar instead immediately changes to "Done waiting", no error, no message box.
Example 2:
Code:
Sub main()
Application.StatusBar = "Waiting 1"
Application.Wait (Now + TimeValue("00:00:10"))
MsgBox ("Message Box")
Application.StatusBar = "Waiting 2"
Application.Wait (Now + TimeValue("00:00:10"))
Application.StatusBar = "Done waiting"
End Sub
Pressing escape during Waiting 1 on this changes the status bar immediately to Waiting 2, then 10 seconds later to Done waiting. No errors or message boxes.
Running both without pressing escape runs as expected with waits and the message box popping up.
Ctrl+Break works correctly in both of these cases, but as I don't currently have a keyboard with a break key, it's a pain using the on-screen keyboard to abort auto-running macros quickly.
Escape also does not trigger the error handler when using Application.EnableCancelKey = xlErrorHandler
It looks like escape is causing vba to skip certain commands (waits), run others (status bar updates), and be interrupted by some others (message box).
Any ideas on what's going on?
Could there be a setting that has been changed on this computer?