« Next-Gen Wifi Avaliable Coming Soon! | Main | BadgerLearn »

Use Alt + F9 to Find and Replace URLs in Word

Last week I was working along merrily in Microsoft Word, using Find and Replace to change URLs in a document, until I realized that I was only changing the link's text... not the URL the link would go to when clicked. In Word, a link's text and its destination URL have to be changed separately if you are using Find and Replace!

Screen shot showing mismatched link text and destination URL

I was worried I was going to have to start over and change each URL by hand, so I Googled up a solution: Alt + F9 is the keystroke to show Field Codes, including destination URLs. After hitting Alt + F9, the destination URL for each link was editable through Find and Replace.

Screen shot after Alt + F9, showing the destination URL for the link

Several Find and Replaces later, I hit Alt + F9 to toggle back to having the destination URLs hidden, and moused over my links to double-check that each link's text matched its destination. Success!

Screen shot showing that the link text and destination URL match

Comments

Feed You can follow this conversation by subscribing to the comment feed for this post.

This does not change the target address of the link. It is true that this process changes what the hover text displays, and F9 field display text, but if you right-click on the link and actually view the hyperlink address, that remains unchanged. And clicking the link will still take you to the original location.

To make this solution work, after making the changes above, you need to select the fields (or Ctrl+A to select everything) and use F9 to update the fields with the change.

Using Alt + F9 *does* work to change the destination URL as described in the post. This is the exact procedure I used to generate the screen shots:

1. Create a Word 2007 document, type in the URL http://overdrivefaq.pbworks.com/ and let Word auto-insert a hyperlink with the same destination URL.

2. Hit Ctrl + F and do a Replace with the following criteria:
Find what: http://overdrivefaq.pbworks.com/
Replace with: http://dbooks.wplc.info/
(This step is described in the first paragraph of the post, and results in the mismatched link text and destination URL seen in the first screen shot.)

3. Hit Alt + F9 to show the destination URL. (This is illustrated in the second screen shot.)

4. Hit Ctrl + F and do a Replace with the following criteria:
Find what: http://overdrivefaq.pbworks.com/
Replace with: http://dbooks.wplc.info/

5. Hit Alt + F9 to toggle back to having the destination URL hidden. (This is illustrated in the third screen shot.) If you right-click and select "Edit Hyperlink," the URLs in "Text to display" and "Address" match.

This method didn't work for me either. However, the following marco did fix the problem for me:
Sub ReplaceHyperlinks()
Dim HL As Hyperlink
Dim target As String
Dim repl As String
target = InputBox("Find address", "Replace Hyperlink")
If Len(target) = 0 Then Exit Sub
repl = InputBox("Replace address", "Replace Hyperlink")
If Len(repl) = 0 Then Exit Sub
For Each HL In ActiveDocument.Hyperlinks
With HL
If InStr(LCase(.Address), LCase(target)) _
Or InStr(LCase(.TextToDisplay), LCase(target)) Then
.Address = Replace(.Address, target, repl)
.TextToDisplay = Replace(.TextToDisplay, target, repl)
.ScreenTip = Replace(.ScreenTip, target, repl)
.Range.Fields.Update
End If
End With
Next
End Sub

April's method...
Alt+F9
global find/replace
ctrl-A and F9

... works PROVIDED you also change the hyperlink base to an appropriate target

(in my case, I used it to remove the absolute path and restore hyperlinks to relative links)

Rose's method worked perfectly for me. This fix saved me changing hundreds of links by hand. I'd switched a database to a new server, which spoiled the links, and Rose's tip--helpfully brought to my attention by a Santa Cruz geek, Jason Wehmhoener--was exactly what I needed. Thank you, Rose--and Jason!

It didn't work for me quite verbatim from the original post, but the comments helped me bridge the gap. Here's what I did:

1. ALT+F9 (This makes all link previews visible inline.)

2. Find & Replace (CTRL+H) the sections that need replacing.

3. CTRL+A (Selects all text.)

4. F9 (This updates the actual links and their previews.)

5. ALT+F9 (This will right the document so that the URLs appear as clickable hyperlinks.)

BTW Thank you for posting this! I couldn't find an answer anywhere else, and this helped me figure it out. Really appreciate you making this public.

Thanks, Rose for the post and Sarah for the clarifying steps. This is perfect.

This was just what I needed. Thanks you!!

worked great for me I just migrated a bunch of DFS storage and relative paths for documentation got screwed up.

I tried the following steps and when I hover over the links, some showed the new urls and some do not, but the ALT + F9 displays the correct link. Please help!

1. ALT+F9 (This makes all link previews visible inline.)

2. Find & Replace (CTRL+H) the sections that need replacing.

3. CTRL+A (Selects all text.)

4. F9 (This updates the actual links and their previews.)

5. ALT+F9 (This will right the document so that the URLs appear as clickable hyperlinks.)

This worked perfectly in Word 2013. Just saved me many hours of editing hundreds of links.

thank you everybody!!!
you saved me with the f9 update!!!

Nice posts.

This is working perfect. A very useful Post.

Post a comment