Item Method

Applies To

AddIns collection object, AutoCaptions collection object, AutoCorrectEntries collection object, AutoTextEntries collection object, Bookmarks collection object, Borders collection object, CaptionLabels collection object, Cells collection object, Characters collection object, Columns collection object, Comments collection object, CustomLabels collection object, Dialogs collection object, Dictionaries collection object, Documents collection object, Endnotes collection object, Fields collection object, FileConverters collection object, FirstLetterExceptions collection object, FontNames object, Footnotes collection object, FormFields collection object, Frames collection object, GroupShapes collection object, HeadersFooters collection object, HeadingStyles collection object, Hyperlinks collection object, Indexes collection object, InlineShapes collection object, KeyBindings collection object, KeysBoundTo collection object, Languages collection object, ListEntries collection object, ListGalleries collection object, ListLevels collection object, ListParagraphs collection object, Lists collection object, ListTemplates collection object, MailMergeDataFields collection object, MailMergeFieldNames collection object, MailMergeFields collection object, PageNumbers collection object, Panes collection object, Paragraphs collection object, ProofreadingErrors collection object, ReadabilityStatistics collection object, RecentFiles collection object, Revisions collection object, Rows collection object, Sections collection object, Sentences collection object, ShapeNodes collection object, ShapeRange collection object, Shapes collection object, SpellingSuggestions collection object, StoryRanges collection object, Styles collection object, Subdocuments collection object, Tables collection object, TablesOfAuthorities collection object, TablesOfAuthoritiesCategories collection object, TablesOfContents collection object, TablesOfFigures collection object, TabStops collection object, Tasks collection object, Templates collection object, TextColumns collection object, TwoInitialCapsExceptions collection object, Variables collection object, Versions collection object, Windows collection object, Words collection object, Zooms collection object.

Description

Returns a member of a collection, either by position or by name.

Syntax

expression.Item(Index)

expression Required. An expression that returns an object in the Applies To list.

Index Required Variant. The name or index number of a member of the collection. The index can be a numeric expression (a number from 1 to the value of the collection's Count property), a constant, or a string. For more information about using the Item method with a specific collection, see the topic for that collection.

Remarks

If the value provided as Index doesn't match any existing member of the collection, an error occurs.

The Item method is the default method for collections. Therefore, the following two lines of code are equivalent.

Application.Documents(1)
Application.Documents.Item(1)
See Also

Count property, First property, Index property, Last property.

Example

This example displays the name of the first document in the Documents collection.

If Documents.Count >= 1 Then
    MsgBox Documents.Item(1).Name
End If
This example selects the bookmark named "temp" in the active document.

If ActiveDocument.Bookmarks.Exists("temp") = True Then
    ActiveDocument.Bookmarks.Item("temp").Select
End If
This example adds two names to the MyNames collection. The Item method is used to return each of the items in the collection.

Dim MyNames As New collection
MyNames.Add Item:="Dave Edson"
MyNames.Add Item:="Tim O'Brien"
MsgBox MyNames.Item(1) & vbCr & MyNames.Item(2)
This example clears all the items from the drop-down form field named "Colors" and then adds two color names. The Item method is used to display the first color in the drop-down form field.

With ActiveDocument.FormFields("Colors").DropDown.ListEntries
    .Clear
    .Add Name:="Blue"
    .Add Name:="Red"
    MsgBox .Item(1).Name
End With