Word VBA教程:BuiltInDocumentProperties属性
来源:百度文库 编辑:神马文学网 时间:2024/04/28 10:06:38
返回一个DocumentProperties集合,该集合代表了指定文档的所有内置的文档属性。
expression.BuiltInDocumentProperties
expression 必需。该表达式返回“应用于”列表中的一个对象。
说明
若要返回代表指定内置文档属性的单一DocumentProperty对象,请使用 BuiltinDocumentProperties(index),其中 index 是一个 WdBuiltInProperty 常量。如需获得有效常量的列表,请参考 Microsoft Visual Basic对象浏览器。有关返回集合中单个成员的内容,请参阅返回集合中的对象。
如果 Microsoft Word 没有为一个内置的文档属性定义一个值,则读取这个文档属性的Value属性时会产生一个错误。
用CustomDocumentProperties属性返回自定义文档属性的集合。
VBA示例
本示例在活动文档的末尾插入一个内置属性列表。
Sub ListProperties()Dim rngDoc As RangeDim proDoc As DocumentPropertySet rngDoc = ActiveDocument.ContentrngDoc.Collapse Direction:=wdCollapseEndFor Each proDoc In ActiveDocument.BuiltInDocumentPropertiesWith rngDoc.InsertParagraphAfter.InsertAfter proDoc.Name & "= "On Error Resume Next.InsertAfter proDoc.ValueEnd WithNextEnd Sub
本示例显示活动文档中的单词数。
Sub DisplayTotalWords()Dim intWords As IntegerintWords = ActiveDocument.BuiltInDocumentProperties(wdPropertyWords)MsgBox "This document contains " & intWords & " words."End Sub
expression.BuiltInDocumentProperties
expression 必需。该表达式返回“应用于”列表中的一个对象。
说明
若要返回代表指定内置文档属性的单一DocumentProperty对象,请使用 BuiltinDocumentProperties(index),其中 index 是一个 WdBuiltInProperty 常量。如需获得有效常量的列表,请参考 Microsoft Visual Basic对象浏览器。有关返回集合中单个成员的内容,请参阅返回集合中的对象。
如果 Microsoft Word 没有为一个内置的文档属性定义一个值,则读取这个文档属性的Value属性时会产生一个错误。
用CustomDocumentProperties属性返回自定义文档属性的集合。
VBA示例
本示例在活动文档的末尾插入一个内置属性列表。
Sub ListProperties()Dim rngDoc As RangeDim proDoc As DocumentPropertySet rngDoc = ActiveDocument.ContentrngDoc.Collapse Direction:=wdCollapseEndFor Each proDoc In ActiveDocument.BuiltInDocumentPropertiesWith rngDoc.InsertParagraphAfter.InsertAfter proDoc.Name & "= "On Error Resume Next.InsertAfter proDoc.ValueEnd WithNextEnd Sub
本示例显示活动文档中的单词数。
Sub DisplayTotalWords()Dim intWords As IntegerintWords = ActiveDocument.BuiltInDocumentProperties(wdPropertyWords)MsgBox "This document contains " & intWords & " words."End Sub
Word VBA教程:BuiltInDocumentProperties属性
Word VBA教程:Execute方法
Word VBA教程:返回集合中的对象
Word VBA教程:Execute方法bbb
VBA教程
VBA - 改变 Word 中对象模型的属性-“十万个为什么”电脑学习网文章收藏
VBA语句集100句 (Word VBA)
Office VBA教程:Execute方法
word教程
Word教程
vba、word和数据库的联合编程
VBA、Word和数据库的联合编程
Word VBA语句集100句
Access教程 第八章 使用VBA编程
Access教程 第八章 使用VBA编程
VBA
vba
(VBA)
word,word教程,word2003教程,word2007教程,word2010教程
vba、word和数据库的联合编程1
Excel 在excel-VBA遍历Word. - Microsoft Office Wo...
Word经典教程
Word 经典教程
word 操作全教程