+ Reply to Thread
Results 1 to 3 of 3

[SOLVED] Code execution has been interrupted

  1. #1
    AnExpertNovice
    Guest

    [SOLVED] Code execution has been interrupted

    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?



  2. #2
    Bob Umlas
    Guest

    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:[email protected]...
    > 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?
    >
    >




  3. #3
    AnExpertNovice
    Guest

    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" <[email protected]> wrote in message
    news:[email protected]...
    > 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:[email protected]...
    > > 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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1