String Manipulation on a file path VBA

Posted on 2008-11-13
Medium Priority
Last Modified: 2013-11-27
Can someone help me with some string manipulation code on a file path using VBA.

Here is an example (please try and give me code that will pertain to any given file path)

"C:\Documents and Settings\w6068c\My Documents\My Pictures\Natan.jpg"

-I need to extract the path of the folder (i.e. "C:\Documents and Settings\w6068c\My Documents\My Pictures")
-The file itself "Natan.jpg"
-And the extension ".jpg"

Thanks In Advance
Question by:npl77
  • 2
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 22955284
dim f as string, filePath as string

f="C:\Documents and Settings\w6068c\My Documents\My Pictures\Natan.jpg"


Author Comment

ID: 22955511
what about the folder path and the extension?
LVL 120

Accepted Solution

Rey Obrero (Capricorn1) earned 2000 total points
ID: 22955560
dim f as string, folderPath as string, x as string, fileName as string

f="C:\Documents and Settings\w6068c\My Documents\My Pictures\Natan.jpg"


fileName=mid(f, instrrev(f,"\")+1)


Featured Post

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

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

This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
In a use case, a user needs to close an opened report by simply pressing the Escape (Esc) key. This can be done by adding macro code in Report_KeyPress or Report_KeyDown event.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

807 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