String Manipulation on a file path VBA

Posted on 2008-11-13
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
    LVL 119

    Expert Comment

    by:Rey Obrero
    dim f as string, filePath as string

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


    Author Comment

    what about the folder path and the extension?
    LVL 119

    Accepted Solution

    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

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Join & Write a Comment

    Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
    Article by: Martin
    Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
    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, when working with VBA, learn some techniques for writing readable and easily maintained code.

    729 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

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now