Function to strip...

  • Thread starter Thread starter SF
  • Start date Start date
S

SF

Hi,

I am working with an image/document dataabase for the organization. I am
looking for a function to strip the PATH of a given file (e.g. strip "D:\My
Photo File" from "D:\My Photo File\image001.jpg")

SF
 
Public Function FileNameOnly(strFullName As String) As String
FileNameOnly = Right(strFullName, Len(strFullName) - InStrRev(strFullName,
"\"))
End Function
 
Thank you. It was great.

SF


Bill Edwards said:
Public Function FileNameOnly(strFullName As String) As String
FileNameOnly = Right(strFullName, Len(strFullName) - InStrRev(strFullName,
"\"))
End Function
 
If the file exists then the Dir function will do what you want

i.e.
?Dir("D:\My Photo File\image001.jpg")
image001.jpg


.... otherwise you'll have to use something like the code Bill Edwards has
posted below
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top