ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Code execution has been interrupted (https://www.excelbanter.com/excel-discussion-misc-queries/63189-code-execution-has-been-interrupted.html)

LAF

Code execution has been interrupted
 

Here's the situation..
I had my wwgpe.xls file open.
I played around with it, but never saved.
I opened another Excel session via the Start menu.
Worked in that new Excel session for a while, and saved.
Went back to the wwgpe.xls file and didn't need it so I clicked the X
at top right.
Received q if I wanted to save.
Responded No.

I then received the "Code execution has been interrupted" problem.
This doesn't seem to be happening for all users on their machines. Is
there any possible fix for this?


--
LAF
------------------------------------------------------------------------
LAF's Profile: http://www.excelforum.com/member.php...fo&userid=9656
View this thread: http://www.excelforum.com/showthread...hreadid=498175


Johan Steyn

This is a huge problem for which nobody on the net has clue about - I have thoroughly searched for answers. I have had this problem for quite a while. There are a few options:

1. If the code is corrupt the code cleaner will work - not in your case though.
2. Rebooting PC sometimes work, but problem comes back.
3. Corruption is probbably in your user profile. I have tested this and it works. When you create a new Windows user profile the problem should dissapear. You can then copy your old profile settings over. This problem is seen in Word as well, I think even Acces.

Your code has nothing to do with your problem. Even if you just create a simple endless loop in a new sub, the problem will occur:

I hope this info will help you.

Do
Loop

Johan Steyn

Another solution is this:

WaitTime=30
Tyd = Timer
On Error GoTo HandleCancel 'trap errors of Cancel bug
Application.EnableCancelKey = xlErrorHandler


-------------Your main code


Exit Sub
HandleCancel:
If Err = 18 Then
If Timer - Tyd WaitTime Then
Answer = MsgBox("Cancel", vbYesNo)
If Answer = vbYes Then Exit Sub
End If
Else: MsgBox Err: Exit Sub

End If
Resume




The WaitTime is the max time your code should run. This is another option in stead of using disabling the cancel key - I just think it is a bit risky. This routine will wait 30 seconds and then re-enable the cancel/break button.


All times are GMT +1. The time now is 06:03 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com