View Single Post
 
Old 12-30-2016, 04:56 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Try the following macro.

Notes:
1. None of the hyperlinks in your document are in paragraphs using the Heading 1 Style - they use a variety of other styles.
2. Some paragraphs have multiple hyperlinks, so only the first one is processed.
3. As coded, the macro adds the new hyperlink to the first word in the paragraph (i.e. the word after the paragraph's #).
Code:
Sub Demo()
Application.ScreenUpdating = False
Dim RngDoc As Range, RngLnk As Range, HLnk As Hyperlink, StrAddr
With ActiveDocument
  Set RngDoc = .Range: Set RngLnk = .Range(0, 0)
  If .TablesOfContents.Count > 0 Then
    RngDoc.Start = .TablesOfContents(.TablesOfContents.Count).Range.End
  End If
End With
For Each HLnk In RngDoc.Hyperlinks
  If HLnk.Range.Paragraphs(1).Range <> RngLnk Then
    Set RngLnk = HLnk.Range.Paragraphs(1).Range
    With RngLnk
      StrAddr = .Hyperlinks(1).Address
      HLnk.Range.Fields(1).Unlink
      .Hyperlinks.Add Anchor:=.Words.First, Address:=StrAddr, TextToDisplay:=.Words.First.Text
    End With
  End If
Next
Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote