+ Reply to Thread
Results 1 to 8 of 8

Detecting Open Workbooks

  1. #1
    Forum Contributor
    Join Date
    03-22-2012
    Location
    OR, USA
    MS-Off Ver
    Excel 14/2010
    Posts
    273

    Detecting Open Workbooks

    I am using VBA to Open a workbook. However, I do not want to open it if it's already open (closing, re-opening would take 5 min because of file size).

    so before I execute

    Please Login or Register  to view this content.
    I need to determine what workbooks are open... I have no idea how to do this...

  2. #2
    Forum Contributor PingPing's Avatar
    Join Date
    02-19-2010
    Location
    London, England
    MS-Off Ver
    2007
    Posts
    158

    Re: Detecting Open Workbooks

    You need to loop through the Workbooks collection.
    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    03-22-2012
    Location
    OR, USA
    MS-Off Ver
    Excel 14/2010
    Posts
    273

    Re: Detecting Open Workbooks

    Your code functions.

    However, it seems to preclude any other actions.

    For example, if I wanted to put up a msgbox stating the file was open (and possibly set that workbook as active), I couldn't because the way the code works it would put a msgbox up for each open workbook.

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Detecting Open Workbooks

    Maybe (untested) ...

    Please Login or Register  to view this content.
    Last edited by shg; 04-18-2012 at 05:20 PM.
    Entia non sunt multiplicanda sine necessitate

  5. #5
    Forum Contributor
    Join Date
    03-22-2012
    Location
    OR, USA
    MS-Off Ver
    Excel 14/2010
    Posts
    273

    Re: Detecting Open Workbooks

    shg you're not forgotten. I got sidetracked with other things. I will get back and test the code soon and let you know how it works for me.

  6. #6
    Forum Contributor
    Join Date
    03-22-2012
    Location
    OR, USA
    MS-Off Ver
    Excel 14/2010
    Posts
    273

    Re: Detecting Open Workbooks

    Please Login or Register  to view this content.
    It pops up with "oops" no matter if the file is open or not.....

  7. #7
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Detecting Open Workbooks

    Try stepping through it. It works fine for me, with the workbook open or closed.

  8. #8
    Forum Contributor
    Join Date
    03-22-2012
    Location
    OR, USA
    MS-Off Ver
    Excel 14/2010
    Posts
    273

    Re: Detecting Open Workbooks

    This works for me:

    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)

Tags for this Thread

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