Re: Extract file name



Here is a UDF which does not rely on a scripting object (meaning it should be a little bit faster)...

Function GetFileName(strFilePath)
GetFileName = Split(strFilePath, "\")(UBound(Split(strFilePath, "\")))
End Function

Rick


"Dana DeLouis" <ddelouis@xxxxxxxxxxxxx> wrote in message news:4C27FC14-76EF-4B2D-82DD-76333473A906@xxxxxxxxxxxxxxxx
What function would extract the name: 84DTCC 2008_05

If you would like a UDF...

Function GetFileName(strFilePath)
GetFileName = CreateObject("Scripting.FileSystemObject").GetFileName(strFilePath)
End Function

Sub TestIt()
Dim s As String
s = "G:\CorporateAcct\SMR\Special\Support\84DTCC 2008_05.pdf"
Debug.Print GetFileName(s)
End Sub

Returns:
84DTCC 2008_05.pdf

--
HTH :>)
Dana DeLouis


"Steven" <Steven@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:00D65A82-8215-4A8C-9934-5A5C6DA93D0E@xxxxxxxxxxxxxxxx
What function would extact the name: 84DTCC 2008_05
out of this.
G:\CorporateAcct\SMR\Special\Support\84DTCC 2008_05.pdf

Note that the directory and subdirectory(ies) will not be constant (ie.
some may have more or less "\" )

Thank you,

Steven

.


Loading