+ Reply to Thread
Results 1 to 2 of 2

What happens if you use vba to open a closed workbook that's already open?

  1. #1
    Registered User
    Join Date
    11-13-2009
    Location
    Cumbria
    MS-Off Ver
    Excel 2016
    Posts
    87

    What happens if you use vba to open a closed workbook that's already open?

    I'm using this code to read from a closed workbook.


    Sub Test()

    Dim wb As Workbook
    Dim AWS

    Application.ScreenUpdating = False

    Set AWS = ActiveSheet

    Set wb = Workbooks.Open("E:\Archive\Test.xlsx", True, True)

    AWS.Range("A1") = wb.Sheets(1).Range("A1")

    wb.Close False

    Application.ScreenUpdating = True

    End Sub
    Please can someone tell me what would happen if the workbook was already open? Could this cause any problems?


    What's the best way of detecting if a workbook is already open?

    Regards,

    Rowan

  2. #2
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: What happens if you use vba to open a closed workbook that's already open?

    This help. It checks to see if the workbook is open if it is uses the open workbook and leaves it open, if its not opens it and closes it.

    Please Login or Register  to view this content.
    Thanks,
    Mike

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.

+ 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