Returning an Object from a Collection
Word Developer Reference |
The Item method returns a single object from a collection. The following example sets the
|
variable to a Document object that represents the first document in the Documents collection.
|
The Item method is the default method for most collections, so you can write the same statement more concisely by omitting the Item keyword.
|
Named Objects
Although you can usually specify an integer value with the Item method, it may be more convenient to return an object by name. The following example switches the focus to a document named Sales.doc.
|
The following example selects the text marked by the first bookmark in the active document.
|
Not all collections can be indexed by name. To determine the valid collection index values, see the collection object topic.
Predefined Index Values
Some collections have predefined index values that you can use to return single objects. Each predefined index value is represented by a constant. For example, you specify a WdBorderType constant with the Borders property to return a single Border object.
The following example adds a single 0.75-point border below the first paragraph in the selection.
|