View Single Post
 
Old 10-17-2020, 09:21 PM
macropod's Avatar
macropod macropod is offline Windows 10 Office 2010
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

With Word 2010 on my laptop, using:
Code:
Sub Test()
' Dimension Variables
Dim eTime As Single, Rvn As Revision, i As Long
' Start Timing
eTime = Timer
With ActiveDocument.Range
  For Each Rvn In .Revisions
    With Rvn
    End With
  Next
  ' Calculate elapsed time
  eTime = (Timer - eTime + 86400) Mod 86400 ' Just in case execution time spans midnight
  MsgBox "Execution took " & Format(eTime / 86400, "hh:mm:ss")
  ' Start Timing
  eTime = Timer
  For i = 1 To .Revisions.Count
    With .Revisions(i)
    End With
  Next
  ' Calculate elapsed time
  eTime = (Timer - eTime + 86400) Mod 86400 ' Just in case execution time spans midnight
  MsgBox "Execution took " & Format(eTime / 86400, "hh:mm:ss")
  ' Start Timing
  eTime = Timer
  For i = .Revisions.Count To 1 Step -1
    With .Revisions(i)
    End With
  Next
  ' Calculate elapsed time
  eTime = (Timer - eTime + 86400) Mod 86400 ' Just in case execution time spans midnight
  MsgBox "Execution took " & Format(eTime / 86400, "hh:mm:ss")
End With
End Sub
the first loop took less than 1 second, the next two took about 1 second each.

Note: It's hardly surprising that a VBA routine might use about 25% (and no more) of a quad-core CPU's capacity.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote