-
I find that hard to believe as well!
I must mentione that I've never encountered a document that has those many word's in them that aren't in the dic or are a spelling error.
So that's why I've probably never asked my self this question because there was no need for it..
But like you it's still on my mind what a possible sollution will look like...
I'll keep on trying stuff for yah! :banghead:
-
Modifying my previous code to include the code below does seem to imply that any reference to a collection of ProofReadingErrors does cause the collection to be rebuilt each time.
I am trying to treat yourErrors as an already built collection and retrieving the ranges that way.
But the time for that loop is almost identical to the time for the 2nd loop in which I explicitly ask for a single member of SpellingErrors each time. In this case, Word is very likely rebuilding the collection each time.
Also, you can see the same behavior for my code samples with much smaller documents, but the absolute time differences are not as large so the issue does not get noticed unless one is looking for this type of detail.
Code:
' yourErrors should now contain the collection of spelling errors.
QueryPerformanceCounter curQPStart
ReDim rngSpellingError(lngSpellingErrorCount - 1)
For i = 0 To lngSpellingErrorCount - 1
Set rngSpellingError(i) = yourErrors(i + 1)
Next i
QueryPerformanceCounter curQPEnd
lngTime = (curQPEnd - curQPStart) / dblQPFreq * 1000
Debug.Print "Copying ranges from collection: " & lngTime
QueryPerformanceCounter curQPStart
ReDim rngSpellingError(lngSpellingErrorCount - 1)
With ActiveDocument.Content
For i = 0 To lngSpellingErrorCount - 1
Set rngSpellingError(i) = .SpellingErrors(i + 1)
Next i
End With
QueryPerformanceCounter curQPEnd
lngTime = (curQPEnd - curQPStart) / dblQPFreq * 1000
Debug.Print "Using ActiveDocument.Content, Copying ranges from collection: " & lngTime
-
I posted a summary of this problem in a MSFT newsgroup yesterday.
Got the expected response.
MSFT's ill conceived implementation of the ProofReadingErrors collection does appear to cause the collection to be recalculated when accessing a member of the collection.
Somebody mentioned that there is a paper on this somewhere.
If I find the paper, I'll let y'all know.
So fer now, I'll mark this thread as Solved, with a very unsatisfactory ending.
-
Yes indeed unsatisfactory when you've spended as much time as you have! :mkay