Version Object

Microsoft Word Visual Basic

Version Object

         
Documents (Document) Versions (Version)

Represents a single version of a document. The Version object is a member of the Versions collection. The Versions collection includes all the versions of the specified document.

Using the Version Object

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

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

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