Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-25-2023, 12:10 AM
Mazarin07 Mazarin07 is offline Relocation of footnotes in the body text and formatting them as needed Windows 10 Relocation of footnotes in the body text and formatting them as needed Office 2019
Novice
Relocation of footnotes in the body text and formatting them as needed
 
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
  #2  
Old 01-25-2023, 12:14 AM
Mazarin07 Mazarin07 is offline Relocation of footnotes in the body text and formatting them as needed Windows 10 Relocation of footnotes in the body text and formatting them as needed Office 2019
Novice
Relocation of footnotes in the body text and formatting them as needed
 
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
Reply

Tags
footnotes

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Relocation of footnotes in the body text and formatting them as needed Preserving formatting when turning footnotes into regular text thiagoafdoria Word VBA 2 01-08-2020 01:25 PM
Relocation of footnotes in the body text and formatting them as needed 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
Relocation of footnotes in the body text and formatting them as needed Help with Tracking: Bold in body text, but not in Footnotes Bobbety Word 3 05-17-2015 11:17 PM
Relocation of footnotes in the body text and formatting them as needed Formatting footnotes causes double footnote numbers geirrosset Word 5 10-29-2014 05:08 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:22 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft