I've devised this macro to remove empty paragraphs before a footnote, that is: paragraphs previously inserted before the footnote mark in the footnote sector. The macro does its job, but I cannot avoid Runtime Error: 5252. Can someone help? Thanks!
Code:
Sub Remove ()
Set rng = ActiveDocument.StoryRanges(wdFootnotesStory)
With rng.Find
.Text = "^13{2;}"
.MatchWildcards = True
.Execute
End With
If rng.Find.Found = True Then
For n = 1 To 10
rng.MoveUntil rng Like "^#"
rng.Select
rng.Collapse Direction:=wdCollapseEnd
rng.MoveUntil rng Like ".", Extend
On Error GoTo Quit
rng.Delete , -1 'Runtime Error: 5252
On Error GoTo 0
Next n
End If
Quit:
End Sub
I modified the macro. The code here below now works perfectly.
Code:
Sub Remove2 ()
Set rng = ActiveDocument.StoryRanges(wdFootnotesStory)
With rng.Find
.Text = "^13{2;}"
.MatchWildcards = True
.Execute
End With
If rng.Find.Found = True Then
rng.MoveUntil rng Like "^#"
rng.Select
For n = 1 To Len(rng) - 1
rng.Collapse Direction:=wdCollapseEnd
rng.MoveUntil rng Like ".", Extend
rng.Delete , -1
Next n
End If
End Sub