![]() |
|
#1
|
|||
|
|||
|
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
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. :-) |
|
#2
|
|||
|
|||
|
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
|
|
| Tags |
| footnotes |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Preserving formatting when turning footnotes into regular text
|
thiagoafdoria | Word VBA | 2 | 01-08-2020 01:25 PM |
Help needed with moving footnotes
|
Last Chance | Word VBA | 15 | 06-07-2019 07:44 PM |
| Normal, Body Text or Body Text Indent? | Riddles | Word | 3 | 04-08-2017 05:06 PM |
Help with Tracking: Bold in body text, but not in Footnotes
|
Bobbety | Word | 3 | 05-17-2015 11:17 PM |
Formatting footnotes causes double footnote numbers
|
geirrosset | Word | 5 | 10-29-2014 05:08 AM |