+ Reply to Thread
Results 1 to 6 of 6

Skipping 'reopen' file prompt box using VBA

  1. #1
    Bhupinder Rayat
    Guest

    Skipping 'reopen' file prompt box using VBA

    Hi all,

    I have a piece of code that opens another spreadsheet, imports some data,
    saves a closes down that file. this file that has shared access so it can be
    updated similtaneously over a network.

    However, if I have this particular file open on my machine and I run the
    above code, I get the prompt box stating,

    "example.xls is already open. Reopening will cause any changes to be
    discarded. Do you want to reopen example.xls?", Yes or No...!

    Is there any way of answering yes to this prompt box within the code so it
    does not appear?

    Thanks in advance,

    Bhupinder Rayat



  2. #2
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Good afternoon Bhupinder

    Have you tried using the DisplayAlerts function?

    This does not answer yes for you but will suppress the question in the first instance.

    Use this line before you re-open the workbook:

    Application.DisplayAlerts=False

    At the end of the code use this to turn the alerts back on:

    Application.DisplayAlerts=True

    I've never actually used it to suppress this particular kind of error, so hope that works OK for you

    HTH

    DominicB

  3. #3
    keepITcool
    Guest

    Re: Skipping 'reopen' file prompt box using VBA


    Bhupinder,

    This will reopen an open file without the warnings..
    but note that any changes are discarded!

    Application.DisplayAlerts = False
    Workbooks.Open (sPath)
    Application.DisplayAlerts = True


    --
    keepITcool
    | www.XLsupport.com | keepITcool chello nl | amsterdam


    Bhupinder Rayat wrote :

    > Hi all,
    >
    > I have a piece of code that opens another spreadsheet, imports some
    > data, saves a closes down that file. this file that has shared access
    > so it can be updated similtaneously over a network.
    >
    > However, if I have this particular file open on my machine and I run
    > the above code, I get the prompt box stating,
    >
    > "example.xls is already open. Reopening will cause any changes to be
    > discarded. Do you want to reopen example.xls?", Yes or No...!
    >
    > Is there any way of answering yes to this prompt box within the code
    > so it does not appear?
    >
    > Thanks in advance,
    >
    > Bhupinder Rayat


  4. #4
    Bhupinder Rayat
    Guest

    Re: Skipping 'reopen' file prompt box using VBA

    keepITcool,

    thanks for that, with a bit a tweeking, it works like a charm!!

    Bhupinder //

    "keepITcool" wrote:

    >
    > Bhupinder,
    >
    > This will reopen an open file without the warnings..
    > but note that any changes are discarded!
    >
    > Application.DisplayAlerts = False
    > Workbooks.Open (sPath)
    > Application.DisplayAlerts = True
    >
    >
    > --
    > keepITcool
    > | www.XLsupport.com | keepITcool chello nl | amsterdam
    >
    >
    > Bhupinder Rayat wrote :
    >
    > > Hi all,
    > >
    > > I have a piece of code that opens another spreadsheet, imports some
    > > data, saves a closes down that file. this file that has shared access
    > > so it can be updated similtaneously over a network.
    > >
    > > However, if I have this particular file open on my machine and I run
    > > the above code, I get the prompt box stating,
    > >
    > > "example.xls is already open. Reopening will cause any changes to be
    > > discarded. Do you want to reopen example.xls?", Yes or No...!
    > >
    > > Is there any way of answering yes to this prompt box within the code
    > > so it does not appear?
    > >
    > > Thanks in advance,
    > >
    > > Bhupinder Rayat

    >


  5. #5
    Registered User
    Join Date
    06-01-2016
    Location
    Toronto, Canada
    MS-Off Ver
    2010
    Posts
    1

    Re: Skipping 'reopen' file prompt box using VBA

    Hi, how were you able to resolve this? I have the same issue, however, if one person is attempting to write to the database, which is an excel document and its open, then another person tries to write after, it will overwrite the first person's entry. I was thinking to build a loop so that if the error occurs, to loop until the workbook is available. Can anyone assist please?

  6. #6
    Registered User
    Join Date
    04-11-2013
    Location
    KSA
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Skipping 'reopen' file prompt box using VBA

    I had the same issue. For me it appeared not related to the workbook containing my vba.
    I noticed this when I tried opening a clean excel file, I noticed that excel was trying to load an add on that I uninstalled
    but its link was still sitting in the addins list. I just went to excel options--->addins ---> and i removed the uninstalled addin
    from the active application list. Close and reopen ... everything went ok.

    Then I opened my excel file containing my vba project, the prompt to reopen the file did not appear.

+ 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