Versions Collection Object

Microsoft Word Visual Basic

Versions Collection Object

         
Documents (Document) Versions (Version)

A collection of Version objects that represent all the versions of a document. Corresponds to the items listed in the Versions dialog box (File menu).

Using the Versions Collection

Use the Versions property to return the Versions collection. The following example turns off the option that automatically creates new document versions.

ActiveDocument.Versions.AutoVersion = wdAutoVersionOff

Use the Save method to add an item to the Versions collection. The following example adds a version with the specified comment.

ActiveDocument.Versions.Save _
    Comment:="incorporated Judy's revisions"

Use Versions(index), where index is the index number, to return a single Version object. The index number represents the position of the version in the Versions collection. The first version added to the Versions collection is index number 1. The following example displays the comment, author, and date of the first version of the active document.

If ActiveDocument.Versions.Count >= 1 Then
    With ActiveDocument.Versions(1)
        MsgBox "Comment = " & .Comment & vbCr & "Author = " & _
            .SavedBy & vbCr & "Date = " & .Date
    End With
End If