BuiltInDocumentProperties 属性

       

返回一个 DocumentProperties 集合,该集合代表了指定文档的所有内置的文档属性。

expression.BuiltInDocumentProperties

expression   必需。该表达式返回“应用于”列表中的一个对象。

说明

若要返回代表指定内置文档属性的单一 DocumentProperty 对象,请使用 BuiltinDocumentProperties(index),其中 index 是一个 WdBuiltInProperty 常量。如需获得有效常量的列表,请参考 Microsoft Visual Basic 对象浏览器。有关返回集合中单个成员的内容,请参阅返回集合中的对象。

如果 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