Change path in hyperlinks

A

Angie M.

Hi,

I have about 100 hyperlinks in a document, they all link to pdf files in the
following location: \\IRFILE\Company\Apps

For example. one hyperlink is:

"\\IRFILE\Company\Apps\PDF\My Client\CLOSING BINDER\TAB 002.pdf"

I want to replace it with:

"F:\Apps\PDF\My Client\CLOSING BINDER\TAB 002.pdf"

the same for all 100 hyperlinks, I just want to replace the first part of
the string with my new location (we moved everything to our new server).

So far I have:

For Each hLink In Documents(1).Hyperlinks
If InStr(hLink.Address, "\\IRFILE\Company\Apps") <> 0 Then
hlink.address, "F:\Apps"
Exit For
End If
Next hLink

I found this code but I'm not sure how to replace just part of the string of
each hyperlink.

Can anybody help?

Thanks!
 
G

Greg Maxey

Try:

Sub Scratchmacro()
Dim hlink As Hyperlink
For Each hlink In Documents(1).Hyperlinks
hlink.Address = Replace(hlink.Address, "\\IRFILE\Company", "F")
Next hlink
End Sub
 
A

Angie M.

THANKS GREG!

Greg Maxey said:
Try:

Sub Scratchmacro()
Dim hlink As Hyperlink
For Each hlink In Documents(1).Hyperlinks
hlink.Address = Replace(hlink.Address, "\\IRFILE\Company", "F")
Next hlink
End Sub
 

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