View Single Post
 
Old 09-04-2019, 07:52 AM
wido wido is offline Windows 10 Office 2016
Novice
 
Join Date: Sep 2019
Posts: 4
wido is on a distinguished road
Default

Oh, it did work! I just had to fix a couple of things that weren't pasted properly from the webpage!! Thank you, solved for me (the original poster did not follow up)!
Copying/pasting here the code that worked. All credit goes to How to fix “This is not a valid action for footnotes” MS Word Error

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
    ' The following line may trigger an error!
    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