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???
 
SOLUTION to this issue. (and other issues as well)

I would describe the workbook I am using as very complex and is about 20mb in size. I use windows xp SP2 with Office 2003 SP3 on my main computer.

I make changes to either data or macro's in this workbook almost daily and with each save of the workbook it increases in size.

I run the same setup on my laptop except there have been no service packs installed for Office.

Every once in a while I will save the workbook on the laptop and the save will reduce the size of the workbook by 2mb or so.

Today I started getting the toxic "Code execution has been interrupted" message and realized that it had been a long while since doing "the save" on the other service pack version of excel.

I saved the workbook on the version of excel with no service packs. Then, without rebooting or adding any code the "Code execution has been interrupted" stopped.

Over the years I have found that saving a workbook on excel installations differing service pack levels has been the solution to many issues.

Hope this helps.
 
Upvote 0

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Over the years I have found that saving a workbook on excel installations differing service pack levels has been the solution to many issues.

Hope this helps.[/QUOTE]

I am still pretty sure that mine started having the code execution error after changing my security settings, but now that you mention it, it may be worth noting that I was using the Microsoft Office 2010 Beta for some time (with no problems and no execution errors), before I reinstalled office 2007 (as a matter of company policy, not my decision). I am pretty sure I used this macro after reinstalling Office 2007 without having the execution error, but I can't really be sure.
 
Upvote 0
I mostly work in 2003, but have saved stuff in 2007 and then went back to 2003, with all available service packs installed. Sometimes the references to the various libraries will be broken when you go back to an earlier version.

If you copy/paste the macro into a new workbook, and establish your references again, it fixes the issue in all cases (for me)
 
Upvote 0
One of the solutions mentioned earlier--shutting down the machine and rebooting entirely, has worked for me. This is of course "The Nuclear Option".

I will try the 'no service pack' method, as I have Virtual PC installed and can maintain a fresh, no sp version of Excel for this. I think if this works it's a 'less nuclear' option and may the best option if one has virtual pc.
--Jim
 
Upvote 0
Well just out of interest: Maybe some of you have found new solutions, or some news on the problem? It appears to go way back to 2002 or so.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:eek:ffice:eek:ffice" /><o:p></o:p>
<o:p></o:p>
To summarise again: The 'code interuption popup' appears while macros runs on any file.<o:p></o:p>
<o:p></o:p>
My own workplace has been hit by this now. My colleague has a spreadsheet with many links, but only about 10 VBA subs. We installed MS Office 2007 about 3 months ago. He got it often. I myself got it just once, hopefully it was a one-off! We use a 3<SUP>rd</SUP> party add-in but luckily the problem seems to be unrelated to add-ins. <o:p></o:p>
<o:p></o:p>
The cut and paste option didn’t work for us. --> Eventually we solved it by putting simply “Application.EnableCancelKey = xlDisabled” at the top of the code of the first sub that runs. J.<o:p></o:p>
<o:p></o:p>
Unfortunately this has to be done separately for each separate workbook that gives the problem. Of course this is because we’re fixing the symptom and not the problem. It seems only MicroSoft can fix the latter. I encourage them to do this, and send all my love and good wishes.<o:p></o:p>
<o:p></o:p>
I took the liberty of pasting a number of attempted remedies below from the web. My sincerest apologies if I'm quoting anybody without their permission.<o:p></o:p>
<o:p></o:p>
Well I'm holding thumbs I stay luckier than my colleague. At least it’s Friday.<o:p></o:p>
<o:p></o:p>
=================<o:p></o:p>
<o:p></o:p>
- Some manual actions:<o:p></o:p>
“Just hit f5 or press ‘continue’ till the end of the run.<o:p></o:p>
<o:p></o:p>
“When the code is interrupted... Click to debug the code and then hit ctrl + break.<o:p></o:p>
<o:p></o:p>
- Application.EnableCancelKey actions.<o:p></o:p>
“At the start of your code: Application.EnableCancelKey = xlDisabled (For Excel) or Application.EnableCancelKey = wdCancelDisabled (For Word) .”<o:p></o:p>
<o:p></o:p>
“Sub X ; Application.EnableCancelKey = XlEnableCancelKey.xlDisabled; Code; Application.EnableCancelKey = XlEnableCancelKey.xlInterrupt.); End Sub.”<o:p></o:p>
<o:p></o:p>
But: “When the macro finishes, the setting will be reset to it's default (even if you don't specify) so there is no need to change the setting back.”<o:p></o:p>
<o:p></o:p>
<o:p></o:p>
- Stop your worksheet from updating your links, while running macros.<o:p></o:p>
For example when an add-in updated a price on the sheet it would give the above error. He deleted the link from edit links.)<o:p></o:p>
<o:p></o:p>
- Service packs.<o:p></o:p>
<o:p></o:p>
Remove them i.e. work on windows, before certain service pack is installed.<o:p></o:p>
<o:p></o:p>
Save Excel files in between PC’s with differing service packs<o:p></o:p>
<o:p></o:p>
<o:p></o:p>
- Tools | Options | Security Tab | Macro Security button = medium<o:p></o:p>
<o:p></o:p>
<o:p></o:p>
- Simply copy & paste code.<o:p></o:p>
“deleting all code, saving, and then reinserting code seems to help some people”<o:p></o:p>
<o:p></o:p>
“cutting code out of modules, compiling and then pasting it back in etc.”<o:p></o:p>
<o:p></o:p>
“In order to actually trigger a rebuild, it is normally necessary to modify a line, and then move the cursor to the next line to flag the source code as modified (e.g. make a change, move cursor down, move cursor up and undo the change manually).”<o:p></o:p>
<o:p></o:p>
- Reboot PC<o:p></o:p>
<o:p></o:p>
- Repair and cleanup actions: ((As a layman I myself am scared of this though))<o:p></o:p>
<o:p></o:p>
Worked apparently: “I copied the workbook in windows explorer and I tried the "Repair Office" utility.”<o:p></o:p>
<o:p></o:p>
Didn’t help much it seems: Run Office’s “detect and repair”. Forgive my ignorance: Are they talking here about [Control panel \ configuration manager \ components \ repair]?<o:p></o:p>
<o:p></o:p>
“Google around on VBA Code Cleaners”<o:p></o:p>
<o:p></o:p>
Worked it looks: “This problem got solved by choosing REPAIR in Control Panel. I guess this explicitly re-registers some of Office's native COM components and does stuff that REINSTALL doesn't. I expect the latter just goes through a checklist and sometimes accepts what's there if it's already installed, maybe. I then had a separate issue with registering my own .NET dll for COM interop on the user's machine (despite this also working on other machines) though I think this was my error rather than Microsoft. Thanks again, I really appreciate it.”<o:p></o:p>
<o:p></o:p>
Attempt, didn’t work I think: “The usual things --- Run Rob Bovey's VBA Code Cleaner on your VBA Code - remove all addins on the users PC, particularly COM and .NET addins - Delete all the users .EXD files (MSoft Update incompatibilities) - Run Excel Detect & Repair on the users system - check the size of the user's .xlb file (should be 20-30K) - Reboot then delete all the users Temp files.”<o:p></o:p>
<o:p></o:p>
<o:p></o:p>
- Re-install Excel <o:p></o:p>
<o:p></o:p>
<o:p></o:p>
- MS Access : you open the .mdb file via a shortcut with the /decompile option (an undocumented option).<o:p></o:p>
<o:p></o:p>
<o:p></o:p>
- Of course a good habit anyway is to always put ‘option explicit’ at the top of all your VBA subs. (It happens automatically if you choose [tools \ options \ require variable checking].) But this did not help us with the problem.<o:p></o:p>
<o:p></o:p>
 
Upvote 0
I have been experiencing this problem for a while now. On my current pc and my previous one. After reading all I could on this issue on other message boards as well as those here I have been able to solve my problem.

For me the problem always resulted from the same action - using ctrl break to interrupt a macro. This would mean that I would randomly get "Code execution has been interrupted" when certain macros are run from that point on until a reboot takes place. The "Code execution has been interrupted" would take me to various places in the code, no problems are in the code and the code has been run thousands of times.

The solution
When the "Code execution has been interrupted" dialogue box appears hit debug and then hit ctrl break again (sometimes it required ctrl break to be hit more than once). This seems to reset what ever setting within excel was set after the first ctrl break.

Thank you for all those who enabled me to get to the solution especially akforsyt.
 
Upvote 0
Thank you so much! It seems to appear under my list of remedies but only now that you've explained it, do I understand what the person meant. My friend tried it and it worked as well. Thanks also to user "akforsyt".
 
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.

This did it for me :biggrin: thank you for posting this.

Preston
 
Upvote 0
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.

This worked a treat for me :biggrin:

I experienced this problem for the first time this morning. I am running Excel 2010 on Windows Vista. I have yet to restart my PC or even close Excel from the first time this happened. I have only checked the internet for answers.
 
Upvote 0
Finally a solution to this problem... only been having this issue for a few years, on different versions, pc's, laptops... simple as Debug then CTRL+BREAK and re run the code.
 
Upvote 0

Forum statistics

Threads
1,216,192
Messages
6,129,432
Members
449,509
Latest member
ajbooisen

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