Index 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