Partager via


DocumentBase.Versions Property

Gets a Versions collection that represents all the versions of the document.

Namespace:  Microsoft.Office.Tools.Word
Assembly:  Microsoft.Office.Tools.Word.v4.0.Utilities (in Microsoft.Office.Tools.Word.v4.0.Utilities.dll)

Syntax

'Declaration
Public ReadOnly Property Versions As Versions
public Versions Versions { get; }

Property Value

Type: Microsoft.Office.Interop.Word.Versions
A Versions collection that represents all the versions of the document.

Examples

The following code example uses the Versions property to save a new version of the document and then displays information about all versions of the document. To use this example, run it from the ThisDocument class in a document-level project.

Private Sub DocumentVersions()
    Dim comment As Object = "My first save." 
    Me.Versions.Save(comment)

    Dim version As Word.Version
    For Each version In Me.Versions
        MessageBox.Show("Version " & version.Index.ToString() & " saved by " _
            & version.SavedBy & " on " & version.Date)
    Next version
End Sub
private void DocumentVersions()
{
    object comment = "My first save.";
    this.Versions.Save(ref comment);

    foreach (Word.Version version in this.Versions)
    {
        MessageBox.Show("Version " + version.Index.ToString() +
            " saved by " + version.SavedBy + " on " +
            version.Date);
    }
}

.NET Framework Security

See Also

Reference

DocumentBase Class

Microsoft.Office.Tools.Word Namespace