View Single Post
 
Old 06-24-2017, 08:38 PM
eduzs eduzs is offline Windows 10 Office 2010 32bit
Expert
 
Join Date: May 2017
Posts: 266
eduzs is on a distinguished road
Default

Thanks for helping, based on your idea we got a workaround to this "bug":

Now I can get rid of unwanted paragraphs breaks and repeated blankspaces.

Code:
Sub Limpa_texto()

Dim i As Integer, oRng As Range, aProc, aSubs

aProc = Array("^13{2;}", "^32{2;}", "^13^32")
aSubs = Array("^p", " ", "^p")

Set oRng = ActiveDocument.Range

Do While Len(ActiveDocument.Range.Paragraphs.Last.Range) = 1

    ActiveDocument.Range.Paragraphs.Last.Range.Delete

Loop

Application.ScreenUpdating = False

For i = 0 To UBound(aProc)

    With oRng.Find

        .Text = aProc(i)
        .Replacement.Text = aSubs(i)
        .Forward = True
        .MatchWildcards = True
        .Wrap = wdFindContinue
        .Execute
        
    End With

    Do While oRng.Find.Found

        oRng.Find.Execute Replace:=wdReplaceAll

    Loop

Next i
    
Application.ScreenUpdating = True

End Sub
__________________
Backup your original file before doing any modification.
Reply With Quote