View Single Post
 
Old 10-17-2020, 02:54 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 Short loop takes no less than 12s to run, uses 25% CPU power!

Do you have any idea about what might cause the loop below to take no less than 12 seconds to run?

Code:
Dim iRev As Long
For iRev = ActiveDocument.Range.Revisions.Count To 1 Step -1
    With ActiveDocument.Range.Revisions(iRev)
    End With
Next iRev

MsgBox ("Finally, the code has executed after 12 seconds...!")
The document has 100 revisions, and I'd like to point out that the 12s execution time is for the code above, as it is written! So, there are no other instructions, or properties to set inside the loop (that could understandably slow it down).

Moreover, the code uses 25% CPU power (winword.exe process).

I run it under Word 2016, on a Core 2 Quad 2.5 Ghz computer, and I'm using the code in a larger macro. All the other subroutines run very fast, except this one which takes so much time to execute. I made sure to test it in its own standalone subroutine to make sure it does not interfere with any other code.

Any idea about what might be the problem, or where I should look for a possible solution to speed it up? I guess it should run in well under a second.

Thank you!

Alex
Reply With Quote