Index Property

Returns the index of an object in its containing collection.

For the Day, Month, Shift, Weekday, and Year objects: Read-only Integer.

For the Pane, Project, and Window objects: Read-only Variant.

For all other objects in the Applies To list: Read-only Long.

Remarks

For the Shift object, the Index property returns a shift number (1, 2, or 3). For the Pane object, the Index property returns 1 for an upper pane or 2 for a lower pane.

Example

The following example switches to a window in the next project with the same index as the active window. This macro can help you compare information between projects that have a similar window arrangement.

For example, if you always put a Gantt chart in the same index of a project's Windows collection, you can display a Gantt chart in one project and then use this macro to easily switch to the Gantt charts of your other projects.

Sub ActivateSameWindowInNextProject()

    ' Check for a next project.
    If ActiveProject.Index = Application.Projects.Count Then
        MsgBox("No more open projects")
    ' Check for an equivalent window in the next project.
    ElseIf ActiveProject.Windows.ActiveWindow.Index > Projects(ActiveProject.Index + 1).Windows.Count Then
        MsgBox("No equivalent window in the next project")
    ' If everything's okay, switch to the window in the next project.
    Else
        Projects(ActiveProject.Index + 1).Windows(ActiveWindow.Index).Activate
    End If

End Sub

Applies to | Assignment Object, Assignments Collection Object | Availability Object, Availabilities Collection Object | Calendar Object, Calendars Collection Object | CodeMaskLevel Object | CostRateTable Object, CostRateTables Collection Object | Day Object, Days Collection Object | Filter Object, Filters Collection Object | Group Object, Groups Collection Object | GroupCriterion Object, GroupCriteria Collection Object | LookupTableEntry Object | Month Object, Months Collection Object | OutlineCode Object, OutlineCodes Collection Object | Pane Object | PayRate Object, PayRates Collection Object | Project Object, Projects Collection Object | Resource Object, Resources Collection Object | Shift Object | SplitPart Object, SplitParts Collection Object | Subproject Object, Subprojects Collection Object | Table Object, Tables Collection Object | TableField Object, TableFields Collection Object | Task Object, Tasks Collection Object | TaskDependency Object, TaskDependencies Collection Object | TimeScaleValue Object, TimeScaleValues Collection Object | View Object, Views Collection Object | ViewCombination Object, ViewsCombination Collection Object | ViewSingle Object, ViewsSingle Collection Object | WeekDay Object, WeekDays Collection Object | Window Object, Windows Collection Object | Year Object, Years Collection Object

See Also | Add Method | Count Property | Delete Method | LastPrintedDate Property