How can I find and replace text in hyperlinks in Word?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have an index/directory document that has lots of network drive references that have changed. Yes. they moved my stuff from drive N: to S: My directory is pretty useless now. How can I find "N:" and replace it with "S:" in hyperlinks only?
 
Gary:
Try the following steps which will allow you to replace n: with s: only in
hyperlinks
1. On the Edit menu, click Replace
2, Move insertion point to Find what box
3. Type "N:" without the quotes
4. Click More
5. Click Format
6. Click Style
7. Select Hyperlink from the list and click OK
8. Move the insertion point to the Replace With box
9. Type "S:" without the quotes
10. Click Format
11. Click Style
12. Select Hyperlink from the list and click OK
13. Click Replace All
 
I think this will work. Use the find and replace tool. Enter the text you want to find/replace. Under Find, select More<Format<Style<Hyperlink. Do the same under replace. I am assuming that the links are active.
 
Note that you need to do this twice: a Find and Replace operation to replace
the display text of the hyperlinks does not change the underlying hyperlink.
To do that, you must press Alt+F9 to display the HYPERLINK field codes and
run a similar replace operation. I got bit by this one just today!

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA

Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
Hi Garry,

' 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


--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.
Hope this helps
Doug Robbins - Word MVP
 
Back
Top