Code Execution has been interrupted
January 19, 2009 1:00 PM   Subscribe

Code Execution has been interrupted:
Continue - End - Debug - Help
*Click Continue*

*Repeat Indefinitely*
Help?!

Hopefully this error will resonate with someone else out there. It sounds hard to believe, but I experience it everyday.

In Excel VBA, you can hit ctrl+break to interrupt your code execution. When you do so, you get a window with the options:
Continue, End, Debug, and Help.

This is useful when you WANT to jump into your code to debug, but I've noticed something odd. If I ctrl-break, then immediately click 'continue' or 'end', 9 times out of 10 (though usually 100% of the time) the code will enter a mode where it will randomly throw the "Code Execution has been interrupted" window as if I hit ctrl-break, even though I didn't.

Clicking Debug to see where it's stopped shows it halting at different lines everytime. Ending then restarting the code doesn't reset anything. Even restarting Excel won't fix it. It's like once that 'mode' gets activated, I'm stuck with it until I restart windows. (which so far is my only sure-fire solution)

I've found 2 workarounds:
1. if the 'mode' hasn't begun and I ctrl-break but then hit the F8 button several times(which advances the code execution by several lines), BEFORE clicking 'end' or 'continue', it doesn't seem to activate the 'weird' mode. (Conversely, if I ctrl-break and then immediately click on END or Continue, without advancing, it will start misbehaving)

2. If I put in the line:
Application.EnableCancelKey = xlDisabled
then this will shut off the Debug window Entirely, allowing the code to finish running without interruption, but it also has the side-effect of preventing ME the ability to ctrl-break, which isn't useful when I'm trying to debug.

I've done a lot of searching on this error over the past couple years (culminating in workaround 2 above), but there doesn't seem to be any useful help for this exact error. I'd love to know what is going on so I can stop it. Having to restart umpteen times a day or disabling code interruption is not making my life very efficient.

Most 'helpers' refuse to even help unless the user posts code, which in this particular error isn't helpful since there is no pattern. In addition, my coworkers aren't able to recreate the error on their computers unless I'm logged in. (indicating to me, it's a profile issue or even a template problem; see 1. below)

There are a few general tips I've found and tried to no avail.
1. VBA bloated templates But I'm not using any templates, unless it's the default one, but I always close "Book1" when I start Excel.

2. third-party add-in(s). I had a couple that were continually trying to load up, but I've disabled them and it doesn't seem to help

3. Export all code and re-import it. This didn't help at all.

So, I'm hoping someone else out there has either experienced this or maybe has some insight on what's going on here.

Thanks
posted by johnstein to Computers & Internet (5 answers total) 1 user marked this as a favorite
 
In the Visual Basic window, go to Debug -> Clear All Breakpoints. Does that help?
posted by sbutler at 1:32 PM on January 19, 2009


Response by poster: No. Doesn't change anything. Thanks for the tip though.
posted by johnstein at 1:35 PM on January 19, 2009


I have experienced this. I think it's just a bug in Excel. It hasn't cropped up recently, but I thought the export-and-reimport thing worked. Perhaps I was just lucky...

One thing I might try is to add:

on error goto errohandler

...to the start of the script, and:

exit sub
errorhandler:
MsgBox Err.Description
Resume Next

...to the end.

to at least see what kind of error it thinks it has found.
posted by pompomtom at 2:58 PM on January 19, 2009


Response by poster: No, that didn't do anything pompomtom. I think it's because it's not an error that is triggering it, it's the VB editor thinking I've interrupted it for debugging.

I suppose this is just too hard of a question for AskMe...

Thanks you both for trying. This is a REALLY frustrating problem and it just happened again today. So I'm going to have to restart AGAIN...

!@%$#*&
posted by johnstein at 7:40 AM on January 20, 2009


I'm with ya. havin the same issue here at the workplace. can't find much on it at all. i could just about strangle excel. reboot isn't helping often either; just using the Application.EnableCancelKey as a workaround for the time being. where is MS on all this???
posted by Frescani at 9:55 AM on April 3, 2009


« Older building computer   |   The Secretary, now what? Newer »
This thread is closed to new comments.