View Single Post
 
Old 10-10-2023, 05:11 AM
yanyan9896 yanyan9896 is offline Windows 10 Office 2019
Novice
 
Join Date: Oct 2023
Posts: 13
yanyan9896 is on a distinguished road
Default

Quote:
Originally Posted by RobiNew View Post
Is there a way to remove extra carriage returns in footnotes with a macro? Thanks!

Try this. I found in Lyonizing Word: Deleting Extraneous Carriage Returns in Footnotes and Endnotes | An American Editor



Code:
Sub CleanReturnsInNotes()

NoteCount = ActiveDocument.Footnotes.Count
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find

.Text = "^p^p"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = False

End With
Selection.Find.Execute
On Error GoTo TrapTheError
While Selection.Find.Found

Selection.MoveLeft

Selection.Delete
Selection.Find.Execute

Wend
GoTo TheEnd
TrapTheError:

ErrorCount = ErrorCount + 1
Selection.MoveRight
Selection.Delete
If ErrorCount < NoteCount Then Resume Next

TheEnd:
End Sub
Reply With Quote