Mass find-replace of hypertext links?

P

patrickd

I have downloaded into Word 2007 a web document that contains numerous
footnotes (actually, endnotes). When I click (CTRL-Click)on a footnote
digit, I am sent back out to the footnote in the original web document on the
internet. I'd like to stay within my local word document.
The endnotes are already bookmarked as note1, note2, etc, but the hyperlink
in the main text bookmark digit sends me to "www.website/docname/#note1" or
something somilar. I can easily edit this to "note1," but since there are
dozens, I'd like to do it with a mass "find-replace all." How can I do this?
 
D

Doug Robbins - Word MVP

I think that the following can be used to do what you want, though in your
case, you would clear the entry from the Input box when it appears:

' Macro created 26/10/01 by Doug Robbins to update links in a document
'
Dim alink As Field, linktype As Range, linkfile As Range
Dim linklocation As Range, i As Integer, j As Integer, linkcode As Range
Dim Message, Title, Default, Newfile
Dim counter As Integer

counter = 0
For Each alink In ActiveDocument.Fields
If alink.Type = wdFieldLink Then
Set linkcode = alink.Code
i = InStr(linkcode, Chr(34))
Set linktype = alink.Code
linktype.End = linktype.Start + i
j = InStr(Mid(linkcode, i + 1), Chr(34))
Set linklocation = alink.Code
linklocation.Start = linklocation.Start + i + j - 1
If counter = 0 Then
Set linkfile = alink.Code
linkfile.End = linkfile.Start + i + j - 1
linkfile.Start = linkfile.Start + i
Message = "Enter the modified path and filename following this
Format " & linkfile
Title = "Update Link"
Default = linkfile
Newfile = InputBox(Message, Title, Default)
End If
linkcode.Text = linktype & Newfile & linklocation
counter = counter + 1
End If
Next alink


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 

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