Previous Document Next Document
Documents.Item

Property Item(Index As Long) As Document

Member of Documents

The Item property returns the specified document. The Item property is the default property and the reference to it can be omitted when referencing items in the collection. For example, Documents.Item(2) is the same as Documents(2) — they both reference the second document in the Documents 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.

Parameters
Description
Index

The following code 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 

The following code 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 2007 Corel Corporation. All rights reserved.