Thread: Edit Hyperlinks
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
JLatham JLatham is offline
external usenet poster
 
Posts: 3,365
Default Edit Hyperlinks

Try this code to fix all hyperlinks in the workbook.

You'll need to change the values for BadString and GoodString - be careful
in making those entries to properly identify the bad section of the URL and
that when the second GoodString is inserted into it, that it comes out
correctly.

I recommend that you try this on a COPY of the workbook - it if works, fine,
if the URLs get messed up, you have the original to make another copy with
and try again.

Sub FixHyperlinks()
Dim anySheet As Worksheet
Dim anyHyperlink As Hyperlink
Const BadString = "/bad/part/bad/part"
Const GoodString = "/bad/part"

For Each anySheet In Worksheets
For Each anyHyperlink In ActiveSheet.Hyperlinks
anyHyperlink.Address = _
Replace(anyHyperlink.Address, BadString, GoodString)
Next
Next
End Sub

If you're unfamiliar with using the VB Editor, use [Alt]+[F11] to open the
editor, choose Insert | Module from the Editor's menus, and just paste the
code into the code area that appears. Close the editor and use Tools | Macro
| Macros and choose the FixHyperlinks entry and click the [Run] button.



"SLKoelker" wrote:

I have a shared workbook with over 2000 hyperlinks. At some point over the
weekend someone (who's rights have since been dissolved) messed up the path
to the documents I had linked. Is there any easy way to remove one section of
the link without having to go through and do each one individually? It looks
like it is mapping to the same folder twice and now nothing will open. So I
have been going in when I can and deleting that extra section to get the
hyperlink to work.

There has to be an easier way. Please help.Thanks.