Code execution has been interrupted

LTrudelle

New Member
Joined
Sep 29, 2006
Messages
1
Here's old problem that nobody has solved yet. It's a long message because it's omplicated.

For the past few years (2002-2006) I have experienced this problem, and so have many other people based on searches across the web.

I write some VBA in Excel 2002 or 2003, in windows XP pro.

After a while, a few hours maybe, the code just stops and shows the error "Code execution has been interrupted", with the 'continue, end, debug' options. Click 'continue' and the code moves along, but then stops later at some other point with the same message.

I have experienced this with more than a dozen projects, ranging from simple apps to complex apps. It occurs randomly and is not related to any specific VBA code.

It happens frequently on one of my PC's, which is a newer XP pro, and a few others I have tried, but does not happen on other PC's that have the same versions of Excel and XP pro.

Many times I have searched the web for answers, and have found many people with the same problem.

I am certain it is caused by some process or event, within Excel or the O/S that is simulating a 'Ctrl-Break'. I have used the following code to verify this:
-----------------------
Sub Test_Interupt()
On Error GoTo errorhandler
'---

'-- trap the Cancel key with an error handler
Application.EnableCancelKey = xlErrorHandler '<--

'-- Do some processing, calculations, worksheet actions, etc
'-- simple or complex, it doesn't make any difference.

'-- A 'cancel' key is being applied here by a process or external event
'-- and it goes to the ErrorHandler

Done:
MsgBox "DONE"
Exit Sub

errorhandler:
If Err.Number = 18 Then Resume Next '<-- user interupted ?
MsgBox "Error: " & Err.Number & " - " & Err.Description, vbCritical
End Sub
-----------------------

I am a seasoned software developer with extensive experience in VB, VB.Net, OOP, and VBA. Please do not ask for samples of code, I assure you there are no bugs in my code.

There has been speculation that it is related to corrupt files (DLL's, OCX's, etc), but nobody has identifed what the file(s) are.

There is speculation that it's caused by XP pro service packs, but this has also never been confirmed.

There has been speculation that Virus software is interupting the VBA, but I have tested it with different virus software and it makes no difference; it runs ok on one PC but not on another with exactly the same configuration.

The only upside is this; so far it seems related to and limited VBA development. Turn on the PC, do some extensive VBA development for a while and the problem starts. Turn off the PC, restart and it works ok for a while. However, if you have compiled the app without any interruptions that it can be run by a user without any problems.

It appears to be limited to VBA development - something is screwing up the memory or system process.

Your solutions are greatly appreciated

-- Larry Trudelle --
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.

Joe Was

MrExcel MVP
Joined
Feb 19, 2002
Messages
7,539
I have only seen this on one PC and only on code that worked with UserForms.

Never found the problem, but unlike you, I thought it was a problem with the dll and regestry?

No thing I tried would fix this problem. I no longer have that PC and none of the other PC's have had the problem?

I tried re-install, reg-fix, reg-edit, office regestry, Excel regester, building the app on a good PC and then installing it on the bad one, converting the app to an Add-in and having other people re-write the code. And as I said no thing worked?
 

hatman

Well-known Member
Joined
Apr 8, 2005
Messages
2,664
I guess I just got indoctrinated into the group, on this one. Sounds like you BOTH have had more experience with this than me, but I will share anyway.

1) Built an addin on the machine in my office.

2) Copied it to my machine down on the shop floor.

3) On the machine on the shop floor, I started tinkering with it... added a USERFORM (bow to Joe).

The userform was the beginnings of help documentation. had he brilliant idea of wlaking through various activities, manipulating the workbook using code, speaking instructions and displaying comment blocks to cue in the user on what was happenning. Then I added this code:

Code:
Application.CommandBars("Pes_Vacation").ShowPopup
application.wait now + timevalue("00:00:02")

BLAMMO :oops:

The code hung... so I hit ctrl-Break.

4) Save addin file.

5) Close excel :oops: Code Execution has been interrupted :oops: during the before close event of another addin.

6) open Excel :oops: Code Execution has been interrupted :oops: during the open event of another addin.

7) Uninstall the offending addin I was working on.

8) Extensive code execution without error.

9) Install the offending addin. execute some random code :oops: Code Execution has been interrupted :oops:

10) Copy the offending userform from the original addin into a new book, uninstall the offending addin, delete that file, copy in the master from the offending addin, install it, copy the offending userform back into that addin from that other book. Save addin, uninstall, close the other book that contained the offending userform. Execute many pieces of code flawlessly... install the offending addin and execuet some code :oops: Code Execution has been interrupted :oops:.

11) DELETE the offending userform from the addin, save, close :oops: Code Execution has been interrupted :oops:, open :oops: Code Execution has been interrupted :oops:, execute some other random code :oops: Code Execution has been interrupted :oops:

12) Copy the master addin back onto the machine, and realize that the Master is 81.1k in size, but the offending addin, which only had the userform added, then deleted (so it should now be identical to the master file) is 95k in size. :eek: WTF :unsure:

Conclusion... Looks to me like this is FILE oriented... if an open file is corrupted, it will impact all code that is run... The corruption seems to be buried in the file. I can pretty much guaruntee that in my case the corruption was housed in the userform somehow... but once that userform got placed into a virgin file, it corrupted some other portion of the file... evidenced by the fact that the file size was altered even after the userform was removed. I mean, I can add a userform to a file, then remove it, and the size reverts to whatever it started as... not so in the case of the corrupted file: something was left behind/altered permanently... something that I just couldn't isolate.

Anyway, I seem to have fixed it here by eliminating all files that ever contained that userform... hope this helps someone else.
 

Forum statistics

Threads
1,136,878
Messages
5,678,301
Members
419,753
Latest member
Sallylwy

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
Top