View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.links
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default How Can I Globally Change Hyperlinks?

The code should be placed in a General module (not behind the worksheet).

Inside the VBE
Insert|Module

And move the code there.

Then double check to make sure you have the old link path correct in the code
(as well as the new link path).

Then select the worksheet with the links (the code uses the ActiveSheet).

Then hit alt-F8 and run the macro.

ps. Make sure your slashes match what you used in the hyperlinks. Hyperlinks
can be pretty forgiving, but string comparisons aren't!

Terry wrote:

On Thu, 13 Aug 2009 12:00:09 -0500, Dave Peterson
wrote:

=So you used the insert|hyperlink version of hyperlinks, right?

Yes

=This is from David McRitchie's site:
=
=Sub Fix192Hyperlinks()
= Dim OldStr As String, NewStr As String
= OldStr = "http://192.168.15.5/"
= NewStr = "http://hank.home.on.ca/"
= Dim hyp As Hyperlink
= For Each hyp In ActiveSheet.Hyperlinks
= hyp.Address = Replace(hyp.Address, OldStr, NewStr)
= Next hyp
=End Sub

I tried this--no joy

=Try something like:

=Option Explicit
=Sub Fix192Hyperlinks()
= Dim OldStr As String, NewStr As String
= OldStr = "E:\Cards\All Cards-For Linking\"
= NewStr = "C:\Cards\SpecialBatch\ALL CARDS-FOR LINKING\"
= Dim hyp As Hyperlink
= For Each hyp In ActiveSheet.Hyperlinks
= hyp.Address = Replace(expression:=hyp.Address, _
= Find:=OldStr, _
= Replace:=NewStr, _
= compa=vbTextCompare)
= Next hyp
=End Sub

And this, too. Still no joy.

I entered a file name, added a hyperlink through the Edit function,
and made sure the link was correct. I changed the link to the new link
and checked it, too. OK. Then changed the link back to the old link.

Next, I put the code in the VB edit window by right-clicking "Sheet
1", selecting "View Code", and typing in the code.

I returned to the sheet through "File"/"Close...and Return..."

Old link still there.

Back to the code. F5 to run. Some crunching somewhere I think...

Back to the sheet. No joy. Still the old adress.

Was this the way to do it?

Groan again + Help!

Be patient--I'm old!

Cheers--

Terry--WB4FXD
Edenton, NC


--

Dave Peterson