S
Steve Wylie
I got this small subroutine off a VBA website. It's supposed to delete
duplicate paragraphs in a document. It looks like it should work, but it
doesn't. It doesn't manage to delete any paragraphs, unless I'm doing
something wrong. Why does it not work? Something simple?
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
Steve Wylie
duplicate paragraphs in a document. It looks like it should work, but it
doesn't. It doesn't manage to delete any paragraphs, unless I'm doing
something wrong. Why does it not work? Something simple?
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
Steve Wylie