Re: Extract file name
- From: "Rick Rothstein \(MVP - VB\)" <rick.newsNO.SPAM@xxxxxxxxxxxxxxxxxx>
- Date: Sat, 9 Aug 2008 04:20:48 -0400
Here is different version which also does not rely on a scripting object...
Function GetFileName(strFilePath)
GetFileName = Mid(strFilePath, InStrRev("\" & strFilePath, "\"))
End Function
Rick
"Rick Rothstein (MVP - VB)" <rick.newsNO.SPAM@xxxxxxxxxxxxxxxxxx> wrote in message news:OtnSKaf%23IHA.3852@xxxxxxxxxxxxxxxxxxxxxxx
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@xxxxxxxxxxxxxxxxWhat 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@xxxxxxxxxxxxxxxxWhat 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
.
- References:
- Extract file name
- From: Steven
- Re: Extract file name
- From: Dana DeLouis
- Re: Extract file name
- From: Rick Rothstein \(MVP - VB\)
- Extract file name
- Prev by Date: Re: Extract file name
- Next by Date: Re: Subtotal question
- Previous by thread: Re: Extract file name
- Next by thread: Can I use an IS function with Vlookup
- Index(es):
Relevant Pages
|