Extract Just Path Location from File Picker  vba Access

Fordraiders
Fordraiders used Ask the Experts™
on
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
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Owner, Dev-Soln LLC
Most Valuable Expert 2014
Top Expert 2010
Commented:
try:

varPath = LEFT(fDialog.SelectedItems(1), InStrRev(fDialog.SelectedItems(1), "\"))
Shaun KlineLead Software Engineer

Commented:
Try this:
   varPath = Left(fDialog.SelectedItems(1), Len(fDialog.SelectedItems(1)) - InStrRev(fDialog.SelectedItems(1), "\") - 1, )

Author

Commented:
Thanks dale.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial