Extract Just Path Location from File Picker vba Access

vba

Using

' To extract only the filename from the path, you can do the following:
   varFilename = Mid(fDialog.SelectedItems(1), InStrRev(fDialog.SelectedItems(1), "\") + 1, Len(fDialog.SelectedItems(1)))
  

Open in new window


The Above gives me
myexcelfile.xls
from
C:\Program Files\MyData\myexcelfile.xls



What I need:
I need to extract just the file Path Location :
C:\Program Files\MyData\

This will not work: it gives me the whole file location path and name:  C:\Program Files\MyData\myexcelfile.xls



thanks
fordraiders
LVL 3
FordraidersAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Dale FyeConnect With a Mentor Commented:
try:

varPath = LEFT(fDialog.SelectedItems(1), InStrRev(fDialog.SelectedItems(1), "\"))
0
 
Shaun KlineLead Software EngineerCommented:
Try this:
   varPath = Left(fDialog.SelectedItems(1), Len(fDialog.SelectedItems(1)) - InStrRev(fDialog.SelectedItems(1), "\") - 1, )
0
 
FordraidersAuthor Commented:
Thanks dale.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.