View Single Post
 
Old 04-04-2023, 08:35 AM
WJSwanepoel WJSwanepoel is offline Windows 10 Office 2021
Advanced Beginner
 
Join Date: Dec 2019
Location: Krugersdorp, South Africa
Posts: 82
WJSwanepoel is on a distinguished road
Question Hyperlink text to Footnote

I am trying to use a macro to turn text at hyperlinks into footnotes. My Macro looks like this:
Code:
Sub HLnk2FtNt()
Application.ScreenUpdating = False
Dim h As Long, Rng As Range
With ActiveDocument
  For h = .Hyperlinks.Count To 1 Step -1
    With .Hyperlinks(h)
      Set Rng = .Range
      With Rng
        .Collapse wdCollapseEnd
        .Footnotes.Add Rng
        .End = .End + 1
      End With
      Rng.Footnotes(1).Range.FormattedText = .Range.FormattedText
      .Range.Fields.Unlink
    End With
  Next
End With
Application.ScreenUpdating = True
End Sub
It however does not do what I want.
I attach the original Word document: SmallTest.docx
The file after running the macro: SmallTest_AfterMacro.docx and
A document showing what I actually want.

Any help will be much appreciated.
Attached Files
File Type: docx SmallTest.docx (12.3 KB, 5 views)
File Type: docx SmallTest_AfterMacro.docx (14.3 KB, 3 views)
File Type: docx SmallTest_Correct.docx (15.5 KB, 3 views)
Reply With Quote