Link to home
Start Free TrialLog in
Avatar of Rayne
RayneFlag for United States of America

asked on

VBA This - File location but not file

Hello,

I have a variable that stores a file path like this

fileLoc = "C:\Here\There\myFile.xls"

Now what splitting or anything I need to do to parse out the file name out of that string and retrun me only string without the filename like this

filLoc now becomes   "C:\Here\There"


what to do in VBA? if I want the strign like this from a full file path...

Thanks
Avatar of Martin Liss
Martin Liss
Flag of United States of America image

Dim intPos As Integer

intPos = InStrRev(fileLoc, "\")
MsgBox Left(fileLoc, intPos - 1)
ASKER CERTIFIED SOLUTION
Avatar of Martin Liss
Martin Liss
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Rayne

ASKER

Thank you Martin, that works Gold :)
You're welcome and I'm glad I was able to help.

Marty - MVP 2009 to 2013