HELP!!! "Code execution has been interrupted"

x-amount

Active Member
Joined
May 16, 2003
Messages
260
But I havent pressed anything!!!

There is definite problem, as the "Code execution has been interrupted" error message appears seemingly at random (although if the workbook doesnt change it is the same points), and for no reason.

If I click the continue button the macro runs exactly as planned, but still there seems to be no rhyme or reason as to why this happens!?

It even invokes on the workboon_open function.

Any ideas???
 
I still believe this is weird as to why it occurs when it only reaches that error on a workbook open command and as said previously it stops at random points and you can just hit continue and it continues to go through the code.

I have encountered this for the first time ever and tried to research why exactly it is happening because it does not seem to be caused by any of the applications mentioned earlier, but I cannot see why or what I did, other than maybe my laptop hasn't been shut down in 5 days and maybe it is running out of memory to run it, but it runs every other macro fine other than ones that open other workbooks? :confused:

Oh well I guess I will re-boot later and see if it goes back to normal.

Sorry for digging up a thread from years ago, but it keeps seeming to come back each year and it hadn't been back in 2009 yet. :biggrin:
 
Upvote 0

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
The biggest problem I have is being able to force it to occur, then force it to stop.

Here's what I DO have so far:

  • It's add-in independent
  • Sometimes rebooting fixes it (temporarily)
  • Exiting Excel and restarting it doesn't fix it.
  • It almost always happens after my initial boot-up, but not "reboots".
I work in a corporate environment and will log off my PC at the end of the day, but not shut it down. Often while I am gone (over the weekends, etc), the corporate behind the scenes servers will push updates and they may or may not reboot the PC, so when I come to work in the morning, I don't know what state the PC is really in, whether waiting for my initial log in after a reboot, or just logging me back in. I can usually tell after I log in, though, because if it's a reboot login, all kinds of server scripts start running.

This morning, I did a rebooted login, and Excel was experiencing the pseudo-random code breaks. I call them "pseudo-random" because Excel will halt at the same lines on functions that are called repeatedly, but from day to day those lines will change. I got fed up enough to attempt a reboot and Excel seems to be running OK so far with no interruptions.

One difference between the initial boot-up this morning and my re-boot. Some of the bootup scripts that the server runs only run on the first bootup of any given day. I think the culprit lies within one of those scripts since the corporate scripts often re-apply the same updates over and over again. It's like they don't trust their systems to have updated Office the first time.. or the second... or...

I'll keep checking on this, but I suggest since a reboot usually clears the problem temporarily, the problem is external to Excel itself (though is probably still a bug in the code somewhere).

I guess I could run ProcMon next time it happens to see if I can trap the culprit.

If any of this info helps, please let me know.

Ace
 
Upvote 0
I'm pretty sure that it's not excel related. I've another (company-internal) program that also reacts to Ctrl-Break events. When Excel suffers from the problem, this program suffers as well. If Excel doesn't suffer, this program doesn't either.

I had the problem now and then on my previous PC. On my new PC, I didn't have it for a month or two, now have it the first time - just after installing Java Runtime Environment... (?).
 
Upvote 0
Hi all - I'm pretty sure I don't have a solution, but here is my experience in case this helps anyone:

- Company's IT department uninstalled/reinstalled Office 2003 for completely unrelated reasons
- Macros seemed to work fine after this. However, MS Query failed to function after this (again, unrelated); I had to run Office's "Detect and Repair" feature to fix this issue
- After running "Detect and Repair", I worked for a couple of days without running macros. Then I ran a few and started seeing this "random" behavior too. I would get "Code execution has been interrupted" on macros that function fine on other machines, and worked on my own before all of this software modification.

The stop did seem to be truly random. A simple Range("A1").Select command would sometimes stop the code.

This is going to make me sound like a real idiot, but here's what fixed my problem: restart Windows. The "detect and repair" function does modify the Windows registry, but it does not prompt you to restart. I didn't even think of it at the time and continued working for days.

Since I've restarted, I haven't seen this error message again (and my other issue with MS Query is resolved too).

The "Detect and Repair" did seem to resolve every issue I had. It takes your MS Office suite back to a 'base' state, so you're going to lose all of your add-ins and settings, but it might be worth a shot if you're still struggling with this error. Just be smarter than me and reboot.
 
Upvote 0
I recently started to experience this problem.
I first became aware of it when I wrote a macro in a workbook that was saved by Excel 2007 into 97-03 format. This could be purely coincidence.

The issue I experienced happened with Word and Excel. Code execution would stop randomly, mostly on "End Sub" or "End If".

I could press continue several times. Sometimes this would cause excel to crash.
I tried the solution to block the break key, but this had NO EFFECT.
I of course reboot my computer when it behaves strangely.

I copied the workbook in windows explorer and I tried the "Repair Office" utility.
All is well _right now_
;)
I searched all over the Internet for a fix for the root cause, but have found nothing.
 
Upvote 0
I hate to post again on this thread which is several months old but I have had this same issue and seem to have found a solution. This problem is the most frustrating thing I have seen while using VBA. There is no reason for the code to be interrupted. The code can be perfectly written and yet you will get "Code execution has been interrupted."

I did not restart my computer, or even excel. I have not deleted any add-ins.
I am using Excel 2007 on Windows XP.

The simple thing that seemed to fix the issue for me... When the code is interrupted... Click to debug the code and then hit ctrl + break.

When you run the code again, it will work fine. Hopefully this will work for others as well.
 
Upvote 0
I have the same issue, with two slight variations.

#1 I have an addin with a class module that transparently monitors every worksheet change. It must run over 100 times a day on my computer (and that is not an exageration).

About 2 or 3 times a week it stops BEFORE any code is run. An f5 continues without any other abnormalities.

If I debug and view the call stack I see that my subroutine is the only entry, and everything looks normal.

=stops here => Private Sub ExcelAvgSumEtcApplication_SheetActivate(ByVal Sh As Object)
If sh.name <> "specialsheet" then exit sub
...


#2. I have a different addin in a different workbook. On open, this addin change the Alt M
key as follows.
Application.OnKey "%m", "AskmacroGlb" ' alt m activate AskMacro

Afterwards, the I use alt M to invoke the addin routines, and AskMacroGlb runs fine. But randomly, about once a day, I type alt M, and it stops before executing the first line of code. F5 proceeds normally, and debug shows nothing wrong.

=stops here => Sub AskMacroGlb()
Dim i, swDbgJune As Boolean, param, cmd
when the users

I have even tried rebuilding the applications using excel workbook rebuilder from vbusers.com.

This roblem has been going on for several years, and I have given up on ever solving it. In a typical day I use f5 about 3 or 4 times, so solving it is no longer a priority.

The addins are used a little on other computers in the company, and occasionally they will have the same problem.

my solution is to tell everybody to use the f5 key to continue.
 
Upvote 0
This problem also comes up in MS Access and there is a sure-fire solution, but I don't know if it is available in Excel.

In access, you open the .mdb file via a shortcut with the /decompile option (an undocumented option). This solves that problem.

I tried this in Excel and it opend the file but never gave control to the file, it was hourglass and no control. Maybe I didn't wait long enough, it was a huge excel file (excel 2007).

Anyway, if anyone knows of any undocumented command-line options for excel (or if the syntax is different from Access) this might be where to explore a solution.
--Jim
 
Upvote 0
I empathize with all of you who are having this problem! It's maddening.

One thing that worked for me was to copy my spreadsheet and in the new version, delete all the modules, then create them again and copy/paste the code from the old into the new.

Also, make sure you compile within VBA to weed out any errors you may have, even in subs that you don't call anymore.
 
Upvote 0
I have just recently started having the same problem. The only thing I have changed is my security and trust settings, so I think the problem must have something to do with that. I hate MS Office security settings, they never work the way you think they will and generally just make using office a pain. Warnings and pop-up messages are fine, but to be forced to shutdown and reopen excel everytime I want to run a macro or save changes or whatever the security pain of the month happens to be is rediculous. So I figured I would just say skrew it and turn off all security settings and now I have to click continue 15 times to complete a relatively short Macro. Office needs to get their s4!t together.

Sorry for the tangent. I think the security and trust center settings is what causes this, because I changed those settings right before I encountered this problem.
 
Upvote 0

Forum statistics

Threads
1,216,225
Messages
6,129,599
Members
449,520
Latest member
TBFrieds

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top