View Single Post
 
Old 06-05-2019, 05:54 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,384
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

The following macro ensures all Footnote & Endnote references are placed after any applicable adjacent punctuation marks. Any preceding space characters are also deleted.
Code:
Sub FootnoteEndnoteFix()
Application.ScreenUpdating = False
Dim FtNt As Footnote, EndNt As Endnote, Rng As Range
With ActiveDocument
  For Each FtNt In .Footnotes
    Set Rng = FtNt.Reference
    With Rng
      'Eliminate any spaces before the footnote
      While .Characters.First.Previous.Text = " "
        .Characters.First.Previous.Text = vbNullString
      Wend
      'Swap the footnote/punctuation, as applicable
      Select Case .Characters.Last.Next
        Case ".", ",", "!", "?", ":", ";"
        .InsertBefore .Characters.Last.Next
        .Characters.Last.Next.Delete
      End Select
    End With
  Next
  For Each EndNt In .Endnotes
    Set Rng = EndNt.Reference
    With Rng
      'Eliminate any spaces before the endnote
      While .Characters.First.Previous.Text = " "
        .Characters.First.Previous.Text = vbNullString
      Wend
      'Swap the endnote/punctuation, as applicable
      Select Case .Characters.Last.Next
        Case ".", ",", "!", "?", ":", ";"
        .InsertBefore .Characters.Last.Next
        .Characters.Last.Next.Delete
      End Select
    End With
  Next
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote