From time to time I note that editing the hyperlink code (r/c, Edit) is not as effective as preserving the address, fixing the link (Ctrl-Shift-F9), and then rebuilding the link (Ctrl-K).
I submit the code knowing that within 15 minutes six different loungers will have streamlined my code to the point where it is no longer recognizable from the original.
I claim, therefore, to be the initiator of some of the best code in the forum .
Code: Select all
Sub ResetHyperlink() If Selection.Hyperlinks.Count = 1 Then Dim rng As Range Set rng = Selection.Hyperlinks(1).Range Dim strText As String strText = rng.Hyperlinks(1).TextToDisplay Dim strLink As String strLink = rng.Hyperlinks(1).Address rng.Fields(1).Unlink ActiveDocument.Hyperlinks.Add Anchor:=rng, Address:=strLink, SubAddress:="", ScreenTip:="", TextToDisplay:=strText Else MsgBox "Please select all or part of a single hyperlink." End If End Sub