代表所有打开的出版物。 “ 文档 ”集合包含在 Microsoft Publisher 中打开的所有 文档 对象。
备注
使用 Documents 属性返回 Documents 集合。
使用 添加 若要向集合中添加新文档的方法。 发布服务器上的新的和可见实例时调用 Add 方法创建。
使用 Item (index) 属性(其中 index 是索引号或文档名称作为 String)返回特定的文档对象。
示例
下面的示例列出了所有打开的出版物。
Dim objDocument As Document
Dim strMsg As String
For Each objDocument In Documents
strMsg = strMsg & objDocument.Name & vbCrLf
Next objDocument
MsgBox Prompt:=strMsg, Title:="Current Documents Open", Buttons:=vbOKOnly
下面的示例将新文档添加到 文档 集合。
Dim objDocument As Document
Set objDocument = Documents.Add
With objDocument
.LayoutGuides.Columns = 4
.LayoutGuides.Rows = 9
.ActiveView.Zoom = pbZoomWholePage
End With
下面的示例显示第一个打开的出版物的名称。
If Documents.Count >= 1 Then
MsgBox Documents.Item(1).Name
End If
下面的示例检查 文档 集合中每个文档的名称。 如果文档的名称 Sales.doc,则对象变量 objSalesDoc 设置为 Documents 集合中的该文档。
Dim objDocument As Document
Dim objSalesDoc As Document
For Each objDocument In Documents
If objDocument.Name = "Sales.doc" Then
Set objSalesDoc = objDocument
End If
Next objDocument
方法
属性
另请参阅
支持和反馈
有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。