Microsoft KB Archive/304020

= Using &quot;For Each&quot; to loop a collection does not allow access to each revision item =

Article ID: 304020

Article Last Modified on 1/31/2007

-

APPLIES TO


 * Microsoft Office Word 2003
 * Microsoft Word 2002 Standard Edition

-



This article was previously published under Q304020





SYMPTOMS
When you use a For Each statement to loop the Activedocument.Range.Revisions collection in Microsoft Word, the expected number of Revision objects is not always returned.

The Revisions.Count reflects more objects than the For Each actually returns.



CAUSE
When the Track Changes option is not selected, it is possible to split a revision (a revision is a contiguous range in a document). There are multiple ways to cause a revision to no longer be contiguous, for example, typing additional characters in an existing revision or inserting a section break in the middle of an existing revision.



WORKAROUND
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.

To work around this problem, use a For Next loop that uses the Revisions collection and ActiveDocument.Range.Revisions.Count. This allows you to access the entire collection. For i = 1 To ActiveDocument.Revisions.Count MsgBox &quot;Format Description: &quot; _ & ActiveDocument.Revisions(i).FormatDescription & &quot; Index number: &quot; _ & ActiveDocument.Revisions(i).Index & &quot; Member number in Count: &quot; & i Next i



STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the &quot;Applies to&quot; section.

Additional query words: prb VBE VBA WD2002 WD2003

Keywords: kbbug KB304020

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.