I returned to this version of my code:
This should be a bug of word vba? I found that the loop/crash ocurrs only when theres a ^p^p at the end of the document.
Sub Limpa_texto()
Application.ScreenUpdating = False
ActiveDocument.Select
With Selection
With .Find
.Text = "^13{2}"
.Replacement.Text = "^13"
.Forward = True
.MatchWildcards = True
.Wrap = wdFindStop
.Execute
End With
Do While .Find.Found
.Find.Execute Replace:=wdReplaceAll
Loop
End With
Application.ScreenUpdating = True
End Sub
__________________
Backup your original file before doing any modification.
|