View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
AnExpertNovice AnExpertNovice is offline
external usenet poster
 
Posts: 36
Default Code execution has been interrupted

Interesting command. It is the Alt-tab + Esc that causes the problem. A
second Esc prevents it. Plus, the problem is caused when no code is
executing and the problem manifests itself when code begins to execute.

Application.EnableCancelKey will be set to xlInterrupt state when the
problem is caused and when it rears it's ugly message box.

Thanks for the command. I can see uses for this one.

--
My handle should tell you enough about me. I am not an MVP, expert, guru,
etc. but I do like to help.


"Bob Umlas" wrote in message
...
Put this as the first statement in your code:
Application.EnableCancelKey = xlDisabled
this effectively turns off the esc key, but if you have a real problem,

like
a loop, you would have to ctrl/alt/delete to stop it.

"AnExpertNovice" wrote in message
...
Is there a way to prevent the "Code execution has been interrupted"

error?
I'm thinking there is not, but perhaps my code is incomplete or

inadequate.

A worksheet has the following event handler: (A similar handler exists

for
the workbook.)

Private Sub Worksheet_Deactivate()
'Redisplay Formula Bar when changing to another worksheet
On Error Resume Next
Application.DisplayFormulaBar = True
End Sub

When I start to Alt-Tab to change to another window and use the Esc key

to
change my mind then the Esc key must be pressed a second time to avoid

the
interruption error when any code is executed. Of course, code will be
executed if I change worksheets, workbooks, click a button, etc.

Any suggestions?