View Single Post
 
Old 01-25-2023, 12:10 AM
Mazarin07 Mazarin07 is offline Windows 10 Office 2019
Novice
 
Join Date: Jan 2023
Posts: 2
Mazarin07 is on a distinguished road
Default Relocation of footnotes in the body text and formatting them as needed

I have the following macro that works almost correctly:

Code:
Sub MoveFootnotesInline()

Dim FtNt As Footnote
Dim RefNum As Long
Dim oRng As Word.Range
Dim rng As Range

Application.ScreenUpdating = False
Set doc = ActiveDocument
Set rng = doc.Footnotes(1).Range
rng.WholeStory
rng.Select
Selection.Range.HighlightColorIndex = wdGray25

For RefNum = ActiveDocument.Footnotes.Count To 1 Step -1
    Set FtNt = ActiveDocument.Footnotes(RefNum)
    Set oRng = FtNt.Reference
     With oRng
      .Collapse wdCollapseStart
      .FormattedText = FtNt.Range.FormattedText
       .Font.ColorIndex = wdRed
      .InsertBefore " [Footnote: " & RefNum
      .InsertAfter "] "
       End With
    FtNt.Delete
  Next RefNum
  Application.ScreenUpdating = True
lbl_Exit:
  Exit Sub
End Sub
The only problem with this code is that doesn't format the reference numbers as required (red color), they actually appear unformatted in the body text, but I would like to show them in red.


P.S.
When we should use this macro?
If you have a Microsoft Word document with many footnotes and want to convert it in e-book format, footnotes will not be shown on older e-book readers (for example PocketBook Basic), so you need to place all footnotes inline, between square brackets, and with 25% gray highlight to make them more distinctive from "normal" text. Setting red color for reference numbers is just an extra, it won't show on black&white old ebook readers, but it became an obsession for me to solve this problem too. :-)
Reply With Quote