Extract FileName from Hyperlink

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.
 
M

mezzanine1974

Sorry
I found.
Dir()
.. as long as hyperlink is not relative

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

monma01 via AccessMonster.com

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
 

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

Top