Question get file name without extension

ramitaherwahdan

New member
Local time
Today, 11:15
Joined
Feb 21, 2011
Messages
9
Dear All,

Thanks for helping... I have a function that I found while googling that catches that file file name and extension from a path. I would like to modify this to catch only the file name without the extension.

here is the code:

Function GetFilenameFromPath(ByVal strPath As String) As String

' Returns the rightmost characters of a string upto but not including the rightmost '\'
' e.g. 'c:\winnt\win.ini' returns 'win.ini'

If Right$(strPath, 1) <> "\" And Len(strPath) > 0 Then
GetFilenameFromPath = GetFilenameFromPath(Left$(strPath, Len(strPath) - 1)) + Right$(strPath, 1)
End If
End Function

Thanks
 
if using A2003 or later, you can use instrrev to find the last . character, and take the leftmost characters up to the .
 

Users who are viewing this thread

Back
Top Bottom