View Single Post
 
Old 01-25-2023, 12:14 AM
Mazarin07 Mazarin07 is offline Windows 10 Office 2019
Novice
 
Join Date: Jan 2023
Posts: 2
Mazarin07 is on a distinguished road
Default

There is another, shorter approach, but this ends with an "Object not found" error message for line "oFootnote.Delete".
Code:
Sub MoveFootnotes()
    Dim oFootnote As Footnote
    Dim oRange As Range
    Dim refNumber As String
    Dim text As String

    For i = ActiveDocument.Footnotes.Count To 1 Step -1
        Set oFootnote = ActiveDocument.Footnotes(i)
        Set oRange = oFootnote.Reference
        refNumber = oRange.text
        text = oFootnote.Range.text
        oRange.text = "[" & refNumber & ": " & text & "]"
        oRange.Font.Color = wdColorRed 'color the reference number to red
        oRange.HighlightColorIndex = wdGray25 'highlight the text in 25% gray
        oFootnote.Delete
    Next
End Sub
If I delete line "oFootnote.Delete" (or simply put an ' sign to make it a remark) the macro works fine, but the end result is that footnote text placed inline is red (in addition to having gray highlight), and the reference numbers are missed, there is a question mark everywhere instead of them.
Reply With Quote