Possible Duplicate:
Excel VBA App stops spontaneously with message “Code execution has been halted”
Why does VBA execution stop at random points within the code with the message "Code execution has been interrupted" unless the following has been specified:
Application.EnableCancelKey = xlDisabled
The stop in the code is similar to a Ctrl+Break key stroke and hence, disabling the Cancel Key (Ctrl+Break) avoids the stop in the execution.
However, disabling the Cancel Key is a bad idea for me because certain scenarios in my code can cause infinite loops (If an OLE request never completes for example) where the ability to use Ctrl+Break is priceless.
I am not too keen on setting EnableCancelKey
to xlErrorHandler
either. It would be better if I could understand the reason for the code interruption and avoid it rather than changing the behavior of the Cancel Key.