I am trying to remove all the occurences of more than 2 carriage returns until no more is found. The text can contain 4 consecutive carriage returns or more, so it can be 5, 8, 10...
I tried this macro copied from this site.
Sub Search3Return()
Dim iCount As Integer
Selection.HomeKey Unit:=wdStory
With Selection.Find
.ClearFormatting
.Text = "^p^p^p"
.Replacement.Text = "^p^p"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchKashida = False
.MatchDiacritics = False
.MatchAlefHamza = False
.MatchControl = False
.MatchByte = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchFuzzy = False
.MatchWildcards = False
.Execute
End With
'If we find one then we can set off a loop to keep checking
'put a counter in to avoid endless loops for one reason or another
Do While Selection.Find.Found = True And iCount < 1000
iCount = iCount + 1
'Jump back to the start of the document.
Selection.HomeKey Unit:=wdStory
Selection.Find.Execute
Loop
End Sub