View Single Post
 
Old 06-07-2019, 11:20 AM
gmaxey gmaxey is offline Windows 10 Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,602
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

This adaptation of Paul's code seems to work to move the after a " ' and .
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
      While Rng.Characters.First.Previous.Text = " "
        Rng.Characters.First.Previous.Text = vbNullString
      Wend
      'Swap the footnote/punctuation, as applicable
      Do
        Set Rng = FtNt.Reference
        Select Case Rng.Characters.Last.Next
          Case ".", ",", "!", "?", ":", ";", "'", """", ChrW(8221), ChrW(8217)
            Rng.InsertBefore Rng.Characters.Last.Next
            Rng.Characters.Last.Next.Delete
          Case Else
            Exit Do
        End Select
      Loop
    Next
    For Each EndNt In .Endnotes
      Set Rng = FtNt.Reference
      While Rng.Characters.First.Previous.Text = " "
        Rng.Characters.First.Previous.Text = vbNullString
      Wend
      'Swap the footnote/punctuation, as applicable
      Do
        Set Rng = FtNt.Reference
        Select Case Rng.Characters.Last.Next
          Case ".", ",", "!", "?", ":", ";", "'", """", ChrW(8221), ChrW(8217)
            Rng.InsertBefore Rng.Characters.Last.Next
            Rng.Characters.Last.Next.Delete
          Case Else
            Exit Do
        End Select
      Loop
    Next
  End With
  Application.ScreenUpdating = True
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote