Index Property
Applies To
AddIn object, AutoCaption object, AutoCorrectEntry object, AutoTextEntry object, Column object, Comment object, CustomLabel object, Endnote object, Field object, FirstLetterException object, Footnote object, HeaderFooter object, ListEntry object, ListLevel object, MailMergeDataField object, MailMergeFieldName object, PageNumber object, Pane object, RecentFile object, Revision object, Row object, Section object, TableOfAuthoritiesCategory object, TwoInitialCapsException object, Variable object, Version object, Window object.
Description
Returns a number that indicates the position of an item in a collection. Read-only Long.
See Also
Count property, Item method, WindowNumber property.
Example
This example adds a document variable to the active document and then returns the position of the variable in the Variables collection.
Set myVar = ActiveDocument.Variables.Add(Name:="Name", Value:="Joe")
num = myVar.Index
This example returns the position of the selected field in the Fields collection.
num = Selection.Fields(1).Index
This example returns the number of the first window in the Windows collection. If there are at least two windows in the Windows collection, the macro activates the next window, copies the first word, switches back to the original window, and inserts the Clipboard contents there.
Set myWindow = Windows(1)
winNum = myWindow.Index
If Windows.Count >= 2 Then
myWindow.Next.Activate
ActiveDocument.Words(1).Copy
Windows(winNum).Activate
Selection.Range.Paste
End If