Previous Document Next Document

Object Model Reference : Classes : D : Documents : Properties : Documents.Item


Documents.Item

Property Item(Index As Long) As Document

Description

Member of Documents

The Item property returns the specified document.

Item is the default property of the Documents class, and its reference can be omitted when you are accessing items in a Documents collection. For example, Documents.Item(2) is the same as Documents(2) — they both reference the second document in the collection.

The order of the documents in the collection represents the order in which the documents were created or opened.

The Item property returns a read-only value.

Parameter
Description
Index
Specifies the preset placeholder that uniquely identifies each member of the Documents collection

VBA example

The following VBA example shows the list of open documents and the number of pages in each of them.

Sub Test()
 Dim i As Long
 Dim s As String
 s = ""
 For i = 1 To Documents.Count
  s = s & "Document #" & i & ": " & Documents(i).Pages.Count & " page(s)" & vbCr
 Next i
 MsgBox s
End Sub
VBA example

The following VBA example performs the same procedure as the previous example. However, instead of using a For Next command, it uses the For Each command in Visual Basic to iterate through all documents in the collection.

Sub Test()
 Dim d As Document
 Dim s As String
 s = ""
 For Each d In Documents
  s = s & "Document #" & d.Index & ": " & d.Pages.Count & " page(s)" & vbCr
 Next d
 MsgBox s
End Sub

Previous Document Next Document Back to Top

Copyright 2013 Corel Corporation. All rights reserved.