Word) (Application.Documents 属性

返回一个 Documents 集合,该集合代表所有打开的文档。 只读。

语法

表达式文件

expression:表示 Application 对象的变量。

备注

有关返回集合的单个成员的信息,请参阅 从集合中返回对象

注意

“受保护的视图”窗口中显示的文档不是 Documents 集合的成员。 请改用 ProtectedViewWindow 对象的 Document 属性来访问“受保护的视图”窗口中显示的文档。

示例

本示例根据 Normal 模板新建一篇文档,然后显示 "另存为" 对话框。

Documents.Add.Save

如果文档在上次保存后进行了修改,本示例将保存该文档。

Dim docLoop As Document 
 
For Each docLoop In Documents 
   If docLoop.Saved = False Then docLoop.Save 
Next docLoop

本示例先将文档的左右边距设置为 0.5 英寸,然后打印所有打开的文档。

Dim docLoop As Document 
 
For Each docLoop In Documents 
    With docLoop 
        .PageSetup.LeftMargin = InchesToPoints(0.5) 
        .PageSetup.RightMargin = InchesToPoints(0.5) 
        .PrintOut 
    End With 
Next docLoop

本示例以只读方式打开文档 Doc.doc。

Documents.Open FileName:="C:\Files\Doc.doc", ReadOnly:=True

另请参阅

Application 对象

支持和反馈

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