Code to Delete Duplicate Paragraphs in a Document:   Return to List

' We turn off screen updating and use the Status Bar to show the User progress through the document -- for purposes of speed of execution.

Public Sub Main()
    Application.ScreenUpdating = False
    For Each Paragraph In ActiveDocument.Paragraphs
        ParaCount = ParaCount + 1
        If Paragraph = MyOldPara Then
            Paragraph.Range.Select
            Selection.Delete
            DeleteCount = DeleteCount + 1
        Else
            MyOldPara = Paragraph
        End If
        Application.StatusBar = " . . . . . . . . . . . . . . . . . . " & _
                    Int(100 * (ParaCount / ActiveDocument.Paragraphs.Count)) & _
                    "% of document scanned and" & Str(DeleteCount) & " paragraphs deleted."
    Next
    Application.ScreenUpdating = True
End Sub



Note to Webmaster