+ Reply to Thread
Results 1 to 11 of 11

Error using Workbooks.open

  1. #1
    Registered User
    Join Date
    02-24-2012
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    9

    Unhappy Error using Workbooks.open

    Hello,

    Hope you guys can help me with this easy question...just driving me nuts over here!

    If I do:
    Please Login or Register  to view this content.
    , excel will open the file. However the following doesn't work:

    Please Login or Register  to view this content.
    What I am trying to achieve is open a new excel file from the current one (to read/write some data) so ideally I would like:

    1) to identify my current excel
    2) open a new one and give it a new identifier
    3) be able to go from one to another

    I am just struggling with opening the file while I assign it to a specific object.

    Thanks for your help,

    Yona
    Last edited by Yona; 02-24-2012 at 12:14 PM. Reason: adding question

  2. #2
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Error using Workbooks.open

    This?
    Please Login or Register  to view this content.

  3. #3
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Error using Workbooks.open

    I think you mean
    Please Login or Register  to view this content.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  4. #4
    Registered User
    Join Date
    02-24-2012
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Error using Workbooks.open

    Uuhhh....nice, that worked just fine. Thanks so much!

  5. #5
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Error using Workbooks.open

    Which worked?

  6. #6
    Registered User
    Join Date
    02-24-2012
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Error using Workbooks.open

    Silly question...but how do I access my cells then?

    i.e. if I want to read "B5" on Tab "Test1" what should I write?

    oWB2.Sheets("Test1").Range("B5").value won't work.

  7. #7
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Error using Workbooks.open

    What do you want to do with it?

  8. #8
    Registered User
    Join Date
    02-24-2012
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Error using Workbooks.open

    Hi Stephen,

    I just want to load the different spreadsheets (files) on oWB1 and oWB2 and then access the values on each one of them.

    i.e.: oWB1.range("B5") = oWB2.range("A1") <-- I know this is missing the tab but just to simplify.

    thanks

  9. #9
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Error using Workbooks.open

    If you create a new file there will be no data to access. You said you wanted to open a new one, to me that means a new workbook not a different one

  10. #10
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Error using Workbooks.open

    This should work:
    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    02-24-2012
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Error using Workbooks.open

    Thanks for this. I believe that the error I was getting was because the Tab I was trying to grab was not present on the file I was opening as a test. So I need one previous IF to check the tab exists or VBA gives an Error.

+ 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