Welcome to the Excel Forum

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed.

Please Register to Remove these Ads

Please Register to Remove these Ads



Reply
  #1  
Old 12-30-2005, 03:15 PM
AnExpertNovice
Guest
 
Posts: n/a
[SOLVED] Code execution has been interrupted

Please Register to Remove these Ads

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?


Reply With Quote
  #2  
Old 12-30-2005, 03:50 PM
Bob Umlas
Guest
 
Posts: n/a
Re: Code execution has been interrupted

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" <j@The~N_o~S_p_a_m~PostOffice.com> wrote in message
news:udVQ1UXDGHA.3820@TK2MSFTNGP12.phx.gbl...
> 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?
>
>



Reply With Quote
  #3  
Old 12-30-2005, 05:30 PM
AnExpertNovice
Guest
 
Posts: n/a
Re: 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" <Excel_Trickster@msn.com> wrote in message
news:eW28WnXDGHA.2036@TK2MSFTNGP14.phx.gbl...
> 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" <j@The~N_o~S_p_a_m~PostOffice.com> wrote in message
> news:udVQ1UXDGHA.3820@TK2MSFTNGP12.phx.gbl...
> > 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?
> >
> >

>
>



Reply With Quote


Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Forum Jump