Extract FileName from Hyperlink

  • Thread starter Thread starter mezzanine1974
  • Start date Start date
M

mezzanine1974

After defining a Hyperlink in a text box, I need to get FileName for
which i defined hyperlink.
If hyperlink is "\\mer_rus_1\Estimating\ABC.pdf", I need to extract
"ABC.pdf" from it.
How can i do that please?

Thank you for any assitance.
 
Sorry
I found.
Dir()
.. as long as hyperlink is not relative

Dir(HyperlinkPart("\\mer_rus_1\Estimating\ABC.pdf", acDisplayedValue))
yields to "ABC.pdf"
 
mezzanine1974 said:
Sorry
I found.
Dir()
.. as long as hyperlink is not relative

Dir(HyperlinkPart("\\mer_rus_1\Estimating\ABC.pdf", acDisplayedValue))
yields to "ABC.pdf"


If you don't need to test for a valid file (which I believe Dir() does), you
could just grab everything after the last "\" by using something like the
following in a standard module:

Sub blah()
Dim strPath As String
Dim strFile As String
Dim intPos As Long
strPath = "\\mer_rus_1\Estimating\ABC.pdf"
intPos = InStrRev(strPath, "\")
strFile = Right(strPath, Len(strPath) - intPos)
Debug.Print strPath
Debug.Print strFile
End Sub

If you open the Immediate Window and type "blah" (because that's the name of
my sub), you should see the following:

blah
\\mer_rus_1\Estimating\ABC.pdf
ABC.pdf
 
Back
Top