+ Reply to Thread
Results 1 to 2 of 2

Prevent workbook from opening in new instnace

  1. #1
    Registered User
    Join Date
    08-09-2013
    Location
    Houston, TX
    MS-Off Ver
    Excel 2007
    Posts
    10

    Prevent workbook from opening in new instnace

    TL,DR: I need a way in VBA to restore how Excel 2010 behaves when opening workbooks.

    I came across a situation in my macro code where I wanted to open a workbook in the background to retrieve some data from it and then close it, preferably without the end-user ever knowing I'd done so. This seemed easy enough to do: I created a new Application, set its Visible state to false, and set the Application variable I used to Nothing when I finished. Worked like a charm, the workbook was opened in the background, read, and closed without the screen even flickering to it.

    But then I started to notice an unfortunate side effect. I normally have my copy of Excel 2010 set up to open all workbooks in the same instance: they occupy the same window even when they appear separately on the taskbar, and when I close an open workbook, Excel switches to a different workbook if one is available. (This is the default setting most of my clients have.) However, after running my macro, future attempts to open workbooks in Excel open in a different instance: closing the newly opened workbook reveals an Excel application with no open workbooks even though there are other workbooks open.

    As the behavior of Excel is different, this is an undesirable bug.

    Ideally, I'd like a means of determining how Excel should handle opening new workbooks (as in whether or not it opens the workbooks in the same instance), and resetting that default behavior after my code executes. At minimum, I'd like to be able to ensure Excel returns to opening workbooks in the same instance. Does anyone have any suggestions on how I could do so?
    Last edited by Brian Drozd; 06-08-2015 at 10:23 AM. Reason: Solved

  2. #2
    Registered User
    Join Date
    08-09-2013
    Location
    Houston, TX
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Prevent workbook from opening in new instnace

    Nevermind. I solved it by adding this before:

    Please Login or Register  to view this content.
    And this after

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Prevent workbook from opening if required Add-in is not installed
    By d.sanchez in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-06-2013, 09:54 PM
  2. Replies: 2
    Last Post: 08-21-2013, 10:00 AM
  3. prevent new workbooks from opening in avtive workbook
    By mkalenuik in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-17-2011, 12:13 PM
  4. Prevent update of links, when opening a workbook
    By AdamParker in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-21-2010, 12:39 PM
  5. Prevent excel from Opening with a new workbook
    By jerrydixon in forum Excel General
    Replies: 1
    Last Post: 08-14-2008, 03:24 PM

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