+ Reply to Thread
Results 1 to 5 of 5

Open a file from parent folder of the activeworkbook

  1. #1
    Registered User
    Join Date
    04-24-2013
    Location
    greece
    MS-Off Ver
    Excel 2007
    Posts
    2

    Open a file from parent folder of the activeworkbook

    Hi am new to the form and vba scripting. I want to open a file that is in the parent folder my workbook I use the command ActiveWorkbook.Path & "\test.xls" and it works
    (....\parentTest\folder\test.xls).
    but I can't find a solution in order to open a file which is located in the "\parentTest\test2.xls".
    Thanking you in advance!

  2. #2
    Forum Contributor
    Join Date
    10-19-2012
    Location
    Omaha, Nebraska USA
    MS-Off Ver
    Excel 2010
    Posts
    249

    Re: Open a file from parent folder of the activeworkbook

    Hi alazari,

    The following code may help. It goes through a routine to find the path for the Activebook's root directory and then opens a file from that directory.

    Please Login or Register  to view this content.
    Hope this helps!

    Daniel

  3. #3
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Open a file from parent folder of the activeworkbook

    Hi, Daniel,

    you may use InStrRev to find the last occurrance (or first from the end) in a string.

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  4. #4
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Open a file from parent folder of the activeworkbook

    You could also do it like this:
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    04-24-2013
    Location
    greece
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Open a file from parent folder of the activeworkbook

    It works perfectly!
    Thank everyone for the immediate responce thanks a lot.

+ 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