Compartilhar via


Revisions Collection Object

Word Developer Reference

A collection of Revision objects that represent the changes marked with revision marks in a range or document.

Remarks

Use the Revisions property to return the Revisions collection. The following example displays the number of revisions in the main text story.

Visual Basic for Applications
  MsgBox ActiveDocument.Revisions.Count

The following example accepts all the revisions in the selection.

Visual Basic for Applications
  For Each myRev In Selection.Range.Revisions
    myRev.Accept
Next myRev

The following example accepts all the revisions in the first paragraph in the selection.

Visual Basic for Applications
  Set myRange = Selection.Paragraphs(1).Range
myRange.Revisions.AcceptAll

The Add method isn't available for the Revisions collection. Revision objects are added when change tracking is enabled. Set the TrackRevisions property to True to track revisions made to the document text. The following example enables revision tracking in the active document and then inserts "The " before the selection.

Visual Basic for Applications
  ActiveDocument.TrackRevisions = True
Selection.InsertBefore "The "

Use Revisions(Index), where Index is the index number, to return a single Revision object. The index number represents the position of the revision in the range or document. The following example displays the author name for the first revision in the first section.

Visual Basic for Applications
  MsgBox ActiveDocument.Sections(1).Range.Revisions(1).Author

The Count property for this collection in a document returns the number of items in the main story only. To count items in other stories use the collection with the Range object.

See Also