共用方式為


Word (Document.BuiltInDocumentProperties 屬性)

會傳回代表指定文件的所有內建文件屬性的 DocumentProperties 集合。

語法

expression. BuiltInDocumentProperties

需要 expression。 代表 Document 物件的變數。

註解

若要傳回單一 DocumentProperty 物件代表特定的內建文件屬性,可以使用 BuiltinDocumentProperties 屬性。 如果 Microsoft Word 不會定義的其中一個內建文件屬性的值,則讀取該文件屬性的 Value 屬性會產生錯誤。

如需傳回集合中單一成員的資訊,請參閱 從集合傳回物件

使用 CustomDocumentProperties 屬性可傳回自訂文件屬性的集合。

範例

本範例會在使用中文件的結尾插入內建屬性清單。

Sub ListProperties() 
 Dim rngDoc As Range 
 Dim proDoc As DocumentProperty 
 
 Set rngDoc = ActiveDocument.Content 
 
 rngDoc.Collapse Direction:=wdCollapseEnd 
 
 For Each proDoc In ActiveDocument.BuiltInDocumentProperties 
 With rngDoc 
 .InsertParagraphAfter 
 .InsertAfter proDoc.Name & "= " 
 On Error Resume Next 
 .InsertAfter proDoc.Value 
 End With 
 Next 
End Sub

本範例會顯示使用中文件裡的字數。

Sub DisplayTotalWords() 
 Dim intWords As Integer 
 intWords = ActiveDocument.BuiltInDocumentProperties(wdPropertyWords) 
 MsgBox "This document contains " & intWords & " words." 
End Sub

另請參閱

Document 物件

支援和意見反應

有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應