Consulting

Results 1 to 3 of 3

Thread: Get current folder name only without rest of path

  1. #1
    VBAX Regular
    Joined
    Aug 2007
    Posts
    6
    Location

    Get current folder name only without rest of path

    I'm looking for the VBA code to get the current folder name. I know the code to get the entire path is ActiveDocument.Path but I only want the part of the path after the last "\". Thanks, this is my first post.

  2. #2
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    There are a few ways to do that. One I use is
    CurrentFolder =Mid(ActiveDocument.Path, InstrRev(ActiveDocument.Path, "\") + 1)
    InstrRev returns the last position in the String of the second argument: ("\")
    Mid returns everything in the String from the position given in its second argument: (InstrRev(Blahblah) + 1))
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  3. #3
    VBAX Regular
    Joined
    Aug 2007
    Posts
    6
    Location
    Thanks Sam. That will work.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •