Solved

Extract Just Path Location from File Picker  vba Access

Posted on 2016-08-17
3
62 Views
Last Modified: 2016-08-17
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
0
Comment
Question by:fordraiders
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 48

Accepted Solution

by:
Dale Fye (Access MVP) earned 500 total points
ID: 41759835
try:

varPath = LEFT(fDialog.SelectedItems(1), InStrRev(fDialog.SelectedItems(1), "\"))
0
 
LVL 26

Expert Comment

by:Shaun Kline
ID: 41759838
Try this:
   varPath = Left(fDialog.SelectedItems(1), Len(fDialog.SelectedItems(1)) - InStrRev(fDialog.SelectedItems(1), "\") - 1, )
0
 
LVL 3

Author Closing Comment

by:fordraiders
ID: 41759941
Thanks dale.
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question