PDA

View Full Version : [SOLVED:] Get current folder name only without rest of path



JohnSW
05-12-2017, 01:36 PM
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.

SamT
05-12-2017, 01:55 PM
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))

JohnSW
05-12-2017, 01:57 PM
Thanks Sam. That will work.