View Single Post
 
Old 10-18-2020, 03:58 AM
alex100 alex100 is offline Windows 7 64bit Office 2016
Advanced Beginner
 
Join Date: May 2020
Posts: 79
alex100 is on a distinguished road
Default

Andrew, Paul, thank you both very much!

I tested your solutions, and in my case, the only one that did improve the execution time was Paul's first loop.

So, for the sake of clarity, here's the code I was using...

Code:
Dim iRev As Long
For iRev = ActiveDocument.Range.Revisions.Count To 1 Step -1
    With ActiveDocument.Range.Revisions(iRev)
        With ActiveDocument.Range.Revisions(iRev)
            Select Case .Type
                Case wdRevisionDelete, wdRevisionCellDeletion
                '
                ' more code here...
                '
                .Reject
            End Select
        End With
    End With
Next iRev
Execution time: 12 seconds

And now, with a major speed improvement (thanks to Paul's code!), I'm using this...

Code:
Dim iRev As Revision
With ActiveDocument.Range
    For Each iRev In .Revisions
        With iRev
            Select Case .Type
                Case wdRevisionDelete, wdRevisionCellDeletion
                '
                ' more code here...
                '
                .Reject
            End Select
        End With
    Next
End With
Execution time: 1 second

Apart from the huge difference in execution time, there are no other differences in the end result.

Alex
Reply With Quote