+ Reply to Thread
Results 1 to 2 of 2

Opened Workbook

  1. #1
    Jiao
    Guest

    Opened Workbook

    I intend to work on an opened workbook using Macro in another workbook. The
    code I use is:

    Dim wk as Workbook
    Set wk=Workbooks.open("c:\a.xls")

    It works when a.xls is closed. But when it is opened. I got a messgae "The
    workbook is already Opened". Does anyone know how? Thanks.
    --
    I like Vb.

  2. #2
    Tom Ogilvy
    Guest

    Re: Opened Workbook

    Dim wk as Workbook
    On Error Resume Next
    set wk = workbooks("a.xls")
    On Error goto 0
    if wk is nothing then
    Set wk=Workbooks.open("c:\a.xls")
    End if

    msgbox wk.Name ' wk now is a reference to a.xls regardless

    --
    Regards,
    Tom Ogilvy


    "Jiao" <Jiao@discussions.microsoft.com> wrote in message
    news:4F596E94-39DE-4C6F-9F03-BC3CC70CCBCD@microsoft.com...
    > I intend to work on an opened workbook using Macro in another workbook.

    The
    > code I use is:
    >
    > Dim wk as Workbook
    > Set wk=Workbooks.open("c:\a.xls")
    >
    > It works when a.xls is closed. But when it is opened. I got a messgae "The
    > workbook is already Opened". Does anyone know how? Thanks.
    > --
    > I like Vb.




+ 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