Hack 28 Unlink Every HyperlinkSometimes uninvited, often distracting, and always hard to wrangle, hyperlinks tend to stick around your documents like unwelcome guests at a party. Here's how to show them the door. Maybe it's because they're so difficult to edit; maybe it's the tacky combination of blue and underline; or maybe it's having to continually dismiss that web browser or email editor you didn't mean to open. Whatever the reason, many users have just one thing to say about hyperlinks in Word: "How do I get rid of them!?"
To unlink a single hyperlink, select it, then right-click and choose Remove Hyperlink from the shortcut menu, as shown in Figure 4-5. Figure 4-5. Removing a hyperlink with the Hyperlink shortcut menuYou can also unlink a hyperlink by selecting it and then pressing Ctrl-Shift-F9. However, this key command unlinks all the fields in the current selection. So selecting all the text in your document and then pressing Ctrl-Shift-F9 would remove all the hyperlinks and unlink every other field in your document, making it a poor choice for the task at hand. Word offers no built-in way to unlink just every hyperlink in a document all at once. However, you can use a macro to get the job done. 4.3.1 The Code
Place this macro in the template of your choice [Hack #50]
and either run it from the Tools Running the following macro achieves the same result as selecting each hyperlink and choosing Remove Hyperlink from the shortcut menu: Sub RemoveAllHyperlinks( ) Dim i As Integer For i = ActiveDocument.Hyperlinks.Count To 1 Step -1 ActiveDocument.Hyperlinks(i).Delete Next i End Sub Notice that while the shortcut menu uses the term "remove," in this macro, each hyperlink is "deleted." Though the terminology is inconsistent, the result is the same: the text remains in your document, but it is no longer an active hyperlink and no longer appears as blue and underlined.
4.3.2 Hacking the Hack
When a hyperlink is inserted into your document (either manually or automatically), the Hyperlink character style is applied to its text. The Hyperlink character style is just like any other character style in Word. You can see it displayed in the Styles pull-down menu on the Formatting toolbar, as shown in Figure 4-6. Figure 4-6. Hyperlink is just another built-in character styleIf you like having the links but can't
stand the blue underlining, you can change it. Select
Format Figure 4-7. Choosing a more mellow format for Word hyperlinksIf you remove a hyperlink, the Hyperlink character style goes with it. The reverse, however, is not truethat is, if you select a hyperlink and alter its styling (e.g., remove the underlining), you will still be left with a fully "clickable" hyperlink.
If you want to remove all the hyperlinks in a document but keep the Hyperlink character style applied to the text, modify the macro as follows: Sub RemoveHyperlinksKeepStyle( ) Dim oHyperlink As Hyperlink Dim i As Integer Dim rng As Range For i = ActiveDocument.Hyperlinks.Count To 1 Step -1 Set oHyperlink = ActiveDocument.Hyperlinks(i) Set rng = oHyperlink.Range oHyperlink.Delete rng.Style = wdStyleHyperlink Next i End Sub To completely remove all the hyperlinks in a document, including their text, change the RemoveAllHyperlinks macro to the following: Sub ReallyRemoveAllHyperlinks( ) Dim i As Integer For i = ActiveDocument.Hyperlinks.Count To 1 Step -1 ActiveDocument.Hyperlinks(i).Range.Delete Next i End Sub |