+ Reply to Thread
Results 1 to 5 of 5

Move up a folder in VBA (EXCEL)

  1. #1
    Buffyslay
    Guest

    Move up a folder in VBA (EXCEL)

    hi

    i am currently using the command

    thisworkbook.path

    if i want to go up a folder, and i was using html i would go ..\ but
    how do i do this in VBA?


  2. #2

    Re: Move up a folder in VBA (EXCEL)


    Try this;


    Sub Test()
    Set fso = CreateObject("scripting.filesystemobject")
    Set x = fso.getfolder(ThisWorkbook.Path)
    MsgBox x.parentfolder
    End Sub


  3. #3
    Buffyslay
    Guest

    Re: Move up a folder in VBA (EXCEL)

    wow - that was easy - thank you very much


  4. #4
    Parag Mahajan
    Guest

    Re: Move up a folder in VBA (EXCEL)

    U can do it using fso as FileSystemObject
    and from there u can get the ParentFolder.

    Hope that helps.
    Parag.
    "Buffyslay" <[email protected]> wrote in message
    news:[email protected]...
    > hi
    >
    > i am currently using the command
    >
    > thisworkbook.path
    >
    > if i want to go up a folder, and i was using html i would go ..\ but
    > how do i do this in VBA?
    >




  5. #5
    Tom Ogilvy
    Guest

    Re: Move up a folder in VBA (EXCEL)

    Depending on what you are doing, you can use "\.."

    for example. If I want to check on the existence of the file File2.xls in
    the directory above the activeworkbook: (demo'd from the immediate window).

    ? activeworkbook.Path
    C:\Data\Data1\Data2
    sStr = ActiveWorkbook.Path & "\..\"
    ? sStr
    C:\Data\Data1\Data2\..\
    ? dir(sStr & "File2.xls")
    file2.xls

    --
    Regards,
    Tom Ogilvy


    "Buffyslay" <[email protected]> wrote in message
    news:[email protected]...
    > wow - that was easy - thank you very much
    >




+ 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