edit hyperlink code cont from 12/8/04

G

Guest

I tried running this without success. Can anybody tell me why?

Sub Fix192Hyperlinks()
'
Dim OldStr As String, NewStr As String
OldStr = "c:\My Templates\Profile Database\"
NewStr = "\\Pinoak\Data\Mfr\Grinding Room\"
Dim hyp As Hyperlink
For Each hyp In ActiveSheet.Hyperlinks
hyp.Address = Replace(hyp.Address, OldStr, NewStr)
Next hyp
End Sub

Thank you
 
R

Ron de Bruin

Do you use Excel 97 Doug ?

Try
hyp.Address = Application.WorksheetFunction.Substitute(hyp.Address, OldStr, NewStr)
 
D

Dave Peterson

Are you sure your activesheet had hyperlinks that matched your OldStr?

Maybe replacing this:
hyp.Address = Replace(hyp.Address, OldStr, NewStr)
with:
hyp.Address = Replace(hyp.Address, OldStr, NewStr, 1, -1, vbTextCompare)

will help.

If you don't specify it (like vbTextCompare), replace is case sensitive.

Check VBA's help for Replace for more info.
 

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