Share via

Application.GetOpenFilename cause an interruption of code

Anonymous
2010-05-25T22:06:41+00:00

When I use application.getopenfilename in a macro it stops processing the macro with "Code execution has been interrupted" after performing the operation. Offers a choice box. Clicking "continue" starts processing again and everything works as intended.

This happens when running it on a vista machine with excel 2003. It does NOT happen when running it with excel 2007 on a windows 7 64 bit machine.

In addition, this behavior started on the vista machine three weeks ago. It ran without this behavior for two years.

What could have happened to cause this? Is there any way to get it to stop doing that?

tghanks

John

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2010-06-01T16:10:51+00:00

The best solution is to copy the code where the issue is occuring to the clipboard.  Then delete the code and reinsert it.  The problem has always gone away for me.

Good Luck,

RC

Was this answer helpful?

2 people found this answer helpful.
0 comments No comments

7 additional answers

Sort by: Most helpful
  1. Anonymous
    2010-05-26T14:05:05+00:00

    I'm aware of the cancelkey solution but in my routine I want the user to be able to click cancel.  I've also read you can get into trouble using this.

    JOhn

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2010-05-26T09:59:22+00:00

    This has been an on-and-off problem for some years now. Nobody seems to know

    what causes it or how to prevent it, but a reboot (or maybe just closing and

    reopening all Office programs) usually clears the problem, although it may

    return. I used to suffer quite a bit from it but rarely see the problem now

    although I have not consciously done anything that might resolve it.

    --

    Enjoy,

    Tony

    www.WordArticles.com

    "Restricted Field" wrote in message

    news:648df1a4-1ed6-44c5-a802-1db92b32b0c2...

    > When I use application.getopenfilename in a macro it stops processing the

    > macro with "Code execution has been interrupted" after performing the

    > operation. Offers a choice box. Clicking "continue" starts processing

    > again and everything works as intended.

    >

    > This happens when running it on a vista machine with excel 2003. It does

    > NOT happen when running it with excel 2007 on a windows 7 64 bit machine.

    >

    > In addition, this behavior started on the vista machine three weeks ago.

    > It ran without this behavior for two years.

    > What could have happened to cause this? Is there any way to get it to stop

    > doing that?

    >

    >

    >

    > tghanks

    >

    > John

    >


    Enjoy,

    Tony

    www.WordArticles.com

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2010-05-26T05:24:25+00:00

    You can try putting this line before the GetOpenFileName command

    Application.EnableCancelKey = xlDisabled

    Remember if you do this you will need to use Ctrl+Break to stop the macro or Ctrl+Alt+Del.

    Save first before testing.


    If this answer solves your problem, please check Mark as Answered. If this answer helps, please click the Vote as Helpful button. Cheers, Shane Devenshire

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2010-05-26T04:34:15+00:00

    John,

    The other day I programmed something at work in a file shared on a network drive.  The program ran perfectly well on my machine, but on my colleagues machine the code interrupted on an API call.  The program was behaving as if I placed a Breakpoint in the code, although I clearly had no breakpoint or any code that would interrupt code execution.  I searched around for some answers, but was unable to come up with anything that fit my situation.  As a quick fix, I simply added an On Error statement before and after the code, simply because I knew that there was no substantial "error."  The On Error statement prevented the code from automatically breaking execution.  If you find out a solution to your problem, I'd be interested in hearing what it may be because it may be similar to my problem.  I included the code I used as a quick fix below.

    Best,

    Matthew Herbert

    On Error Resume Next

    'Application.GetOpenFilename code here

    On Error GoTo 0

    Was this answer helpful?

    0 comments No comments