Removing 1 or more Hyperlinks from Document:   Return to List

' The BEST way to remove a hyperlink is with the command:
Selection.Range.Fields.Unlink

' This will unlink a single hyperlink or all of the hyperlinks (depending on the selection). The advantage over commands such as "ActiveDocument.Hyperlinks.Delete" or "ActiveDocument.Hyperlinks.Item(1).Delete" is that it will not throw an error if a hyperlink doesn't exist -- as these commands will.  Also when cycling through the document, selecting hyperlinks and deleting them one by one (perhaps an operation is being performed at each hyperlink) you don't have to worry about the particular hyperlink item number in order to delete it. You're simply unlinking whatever might be linked at the selection.

Dim myHyp as Hyperlink
For each myHyp in ActiveDocument.Hyperlinks
    myHyp.Range.Select
    ' Do whatever
    Selection.Range.Fields.Unlink
    lngCount = lngCount + 1
Next
MsgBox "There were " & CStr(lngCount) & " hyperlinks removed from the document."

' To remove all of the hyperlinks in a document, simply do the following:

ActiveDocument.Select
intLinks = ActiveDocument.Hyperlinks.Count
Selection.Range.Fields.Unlink
Selection.End = Selection.Start ' to put cursor at top of doc
MsgBox "There were " & CStr(intLinks) & " hyperlinks removed from the document.

See also:
Adding Hyperlink to a Document
Hyperlink extraction to 2nd doc (very useful)



Note to Webmaster