共用方式為


DocumentLibraryVersion 物件 (Office)

DocumentLibraryVersion 物件代表已啟用版本設定的共用文件的單一已儲存版本,並儲存在伺服器上的文件庫中。 每個 DocumentLibraryVersion 物件是使用中文件的 DocumentLibraryVersions 集合的成員。

註解

每部 DocumentLibraryVersion 物件代表使用中文件的一個儲存的版本。 啟用版本設定時,建立新版本的伺服器上下面所列的動作發生; 時其他版本不會建立每次使用者儲存開啟的文件的變更。

  • 入住
  • 儲存:當使用者開啟文件後首次儲存文件時,會在伺服器上建立新版本。 將檔案開啟期間所儲存的其他變更套用到相同的版本。
  • Restore
  • Upload

使用 ModifiedModifiedByComments 屬性可傳回共用文件儲存版本的相關資訊。

Open 方法來開啟先前版本或還原舊版的目前版本取代的 還原 方法使用。 使用 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 支援與意見反應