+ Reply to Thread
Results 1 to 9 of 9

How do I access an unopened spreadsheet from a program?

  1. #1
    Pete at Sappi Fine Paper
    Guest

    How do I access an unopened spreadsheet from a program?

    Hi folks.

    The Workbooks keyword only seems to work for spreadsheets that are already
    open. I can't seem to say, for example:

    wkb = Workbooks("Y:\Downloads\6-7.xls")

    So how do I refer to cells in that spreadsheet without opening it?

    Any help would be much appreciated!

    -Pete

  2. #2
    Tom Ogilvy
    Guest

    Re: How do I access an unopened spreadsheet from a program?

    VBA doesn't support that. You can use an excel 4 macro command. You can
    put a linking formula in a cell, and read the value returned, then clear the
    formula (usually the fastest). You can use ADO to treat the closed workbook
    as a data base. You can open the workbook, get the data, then close it.

    Probably other ways as well.

    --
    Regards,
    Tom Ogilvy


    "Pete at Sappi Fine Paper" <[email protected]>
    wrote in message news:[email protected]...
    > Hi folks.
    >
    > The Workbooks keyword only seems to work for spreadsheets that are already
    > open. I can't seem to say, for example:
    >
    > wkb = Workbooks("Y:\Downloads\6-7.xls")
    >
    > So how do I refer to cells in that spreadsheet without opening it?
    >
    > Any help would be much appreciated!
    >
    > -Pete




  3. #3
    John.Greenan
    Guest

    RE: How do I access an unopened spreadsheet from a program?

    try this....

    Sub test()

    Dim x As Excel.Workbook

    Set x = Workbooks.Open("c:\book4.xls")
    End Sub

    Swap "book4.xls" for your workbook name.

    Good luck.

    --
    www.alignment-systems.com


    "Pete at Sappi Fine Paper" wrote:

    > Hi folks.
    >
    > The Workbooks keyword only seems to work for spreadsheets that are already
    > open. I can't seem to say, for example:
    >
    > wkb = Workbooks("Y:\Downloads\6-7.xls")
    >
    > So how do I refer to cells in that spreadsheet without opening it?
    >
    > Any help would be much appreciated!
    >
    > -Pete


  4. #4
    Pete at Sappi Fine Paper
    Guest

    RE: How do I access an unopened spreadsheet from a program?

    Thanks John. Unfortunately this solution opens the spreadsheet in question,
    which I am trying to avoid. It's a huge spreadsheet and takes forever to
    open. I need to access the data in the spreadsheet without opening it.

    "John.Greenan" wrote:

    > try this....
    >
    > Sub test()
    >
    > Dim x As Excel.Workbook
    >
    > Set x = Workbooks.Open("c:\book4.xls")
    > End Sub
    >
    > Swap "book4.xls" for your workbook name.
    >
    > Good luck.
    >
    > --
    > www.alignment-systems.com
    >
    >
    > "Pete at Sappi Fine Paper" wrote:
    >
    > > Hi folks.
    > >
    > > The Workbooks keyword only seems to work for spreadsheets that are already
    > > open. I can't seem to say, for example:
    > >
    > > wkb = Workbooks("Y:\Downloads\6-7.xls")
    > >
    > > So how do I refer to cells in that spreadsheet without opening it?
    > >
    > > Any help would be much appreciated!
    > >
    > > -Pete


  5. #5
    Pete at Sappi Fine Paper
    Guest

    Re: How do I access an unopened spreadsheet from a program?

    Thanks Tom. I was afraid of that. If it won't take too long to explain,
    what is ADO?

    "Tom Ogilvy" wrote:

    > VBA doesn't support that. You can use an excel 4 macro command. You can
    > put a linking formula in a cell, and read the value returned, then clear the
    > formula (usually the fastest). You can use ADO to treat the closed workbook
    > as a data base. You can open the workbook, get the data, then close it.
    >
    > Probably other ways as well.
    >
    > --
    > Regards,
    > Tom Ogilvy
    >
    >
    > "Pete at Sappi Fine Paper" <[email protected]>
    > wrote in message news:[email protected]...
    > > Hi folks.
    > >
    > > The Workbooks keyword only seems to work for spreadsheets that are already
    > > open. I can't seem to say, for example:
    > >
    > > wkb = Workbooks("Y:\Downloads\6-7.xls")
    > >
    > > So how do I refer to cells in that spreadsheet without opening it?
    > >
    > > Any help would be much appreciated!
    > >
    > > -Pete

    >
    >
    >


  6. #6
    Amedee Van Gasse
    Guest

    Re: How do I access an unopened spreadsheet from a program?

    Pete at Sappi Fine Paper shared this with us in
    microsoft.public.excel.programming:

    > Hi folks.
    >
    > The Workbooks keyword only seems to work for spreadsheets that are
    > already open. I can't seem to say, for example:
    >
    > wkb = Workbooks("Y:\Downloads\6-7.xls")
    >
    > So how do I refer to cells in that spreadsheet without opening it?
    >
    > Any help would be much appreciated!
    >
    > -Pete


    Read this page:

    Copy a range from closed workbooks (ADO)
    http://www.rondebruin.nl/ado.htm

    And this also:
    http://www.rondebruin.nl/tips.htm

    It's not a direct answer to your question, but a good workaround.

    --
    Amedee Van Gasse

  7. #7
    Tom Ogilvy
    Guest

    Re: How do I access an unopened spreadsheet from a program?

    http://msdn.microsoft.com/library/de...mmersguide.asp

    --
    Regards,
    Tom Ogilvy


    "Pete at Sappi Fine Paper" <[email protected]>
    wrote in message news:[email protected]...
    > Thanks Tom. I was afraid of that. If it won't take too long to explain,
    > what is ADO?
    >
    > "Tom Ogilvy" wrote:
    >
    > > VBA doesn't support that. You can use an excel 4 macro command. You

    can
    > > put a linking formula in a cell, and read the value returned, then clear

    the
    > > formula (usually the fastest). You can use ADO to treat the closed

    workbook
    > > as a data base. You can open the workbook, get the data, then close it.
    > >
    > > Probably other ways as well.
    > >
    > > --
    > > Regards,
    > > Tom Ogilvy
    > >
    > >
    > > "Pete at Sappi Fine Paper"

    <[email protected]>
    > > wrote in message

    news:[email protected]...
    > > > Hi folks.
    > > >
    > > > The Workbooks keyword only seems to work for spreadsheets that are

    already
    > > > open. I can't seem to say, for example:
    > > >
    > > > wkb = Workbooks("Y:\Downloads\6-7.xls")
    > > >
    > > > So how do I refer to cells in that spreadsheet without opening it?
    > > >
    > > > Any help would be much appreciated!
    > > >
    > > > -Pete

    > >
    > >
    > >




  8. #8
    Harald Staff
    Guest

    Re: How do I access an unopened spreadsheet from a program?

    "Pete at Sappi Fine Paper" <[email protected]>
    skrev i melding news:[email protected]...
    > Thanks Tom. I was afraid of that. If it won't take too long to explain,
    > what is ADO?


    Hi Pete

    ActiveX Data Objects -a great common set of objects for all kinds of
    databases. See Carl Prothman's site
    http://www.carlprothman.net/Default.aspx?tabid=80
    for expert insight, and
    http://erlandsendata.no/english/inde...dacimportwbado
    on how to use this with Excel as a database.

    HTH. Best wishes Harald



  9. #9
    Pete at Sappi Fine Paper
    Guest

    Re: How do I access an unopened spreadsheet from a program?

    Thanks!

    "Amedee Van Gasse" wrote:

    > Pete at Sappi Fine Paper shared this with us in
    > microsoft.public.excel.programming:
    >
    > > Hi folks.
    > >
    > > The Workbooks keyword only seems to work for spreadsheets that are
    > > already open. I can't seem to say, for example:
    > >
    > > wkb = Workbooks("Y:\Downloads\6-7.xls")
    > >
    > > So how do I refer to cells in that spreadsheet without opening it?
    > >
    > > Any help would be much appreciated!
    > >
    > > -Pete

    >
    > Read this page:
    >
    > Copy a range from closed workbooks (ADO)
    > http://www.rondebruin.nl/ado.htm
    >
    > And this also:
    > http://www.rondebruin.nl/tips.htm
    >
    > It's not a direct answer to your question, but a good workaround.
    >
    > --
    > Amedee Van Gasse
    >


+ 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