DocumentLibraryVersion 对象 (Office)

DocumentLibraryVersion 对象表示已启用版本控制并存储在服务器上的文档库中的共享文档的单个已保存版本。 每个 DocumentLibraryVersion 对象都是该活动文档的 DocumentLibraryVersions 集合中的一个成员。

备注

每个 DocumentLibraryVersion 对象表示活动文档的一个已保存版本。 启用版本控制后,发生下面列出的操作时,将在服务器上创建一个新版本:每次用户将更改保存到打开的文档时,都不会创建其他版本。

  • 签入
  • 保存:当用户在打开文档后首次保存文档时,会在服务器上创建新版本。 在打开文档时所保存的其他更改也将应用于同一版本。
  • 还原
  • 上传

使用 ModifiedModifiedByComments 属性可返回有关共享文档已保存版本的信息。

使用 Open 方法可打开以前的版本,或者使用 Restore 方法还原以前的版本来替代当前版本。 使用 Delete 方法可删除版本。

示例

下面的示例显示了活动文档各个已保存版本的属性。

 Dim dlvVersions As Office.DocumentLibraryVersions 
 Dim dlvVersion As Office.DocumentLibraryVersion 
 Dim strVersionInfo As String 
 Set dlvVersions = ActiveDocument.DocumentLibraryVersions 
 If dlvVersions.IsVersioningEnabled Then 
 strVersionInfo = "This document has " & _ 
 dlvVersions.Count & " versions: " & vbCrLf 
 For Each dlvVersion In dlvVersions 
 strVersionInfo = strVersionInfo & _ 
 " - Version #: " & dlvVersion.Index & vbCrLf & _ 
 " - Modified by: " & dlvVersion.ModifiedBy & vbCrLf & _ 
 " - Modified on: " & dlvVersion.Modified & vbCrLf & _ 
 " - Comments: " & dlvVersion.Comments & vbCrLf 
 Next 
 Else 
 strVersionInfo = "Versioning not enabled for this document." 
 End If 
 MsgBox strVersionInfo, vbInformation + vbOKOnly, "Version Information" 
 Set dlvVersion = Nothing 
 Set dlvVersions = Nothing 

另请参阅

支持和反馈

有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。