WeekDay.Index Property

Project Developer Reference

Returns the index of an object in its containing collection. Read-only Integer.



expression   A variable that represents a WeekDay object.

Return Value


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.

Visual Basic for Applications
  Sub ActivateSameWindowInNextProject()
' Check for a next project.
If ActiveProject.<strong class="bterm">Index</strong> = Application.Projects.Count Then
    MsgBox("No more open projects")
' Check for an equivalent window in the next project.
ElseIf ActiveProject.Windows.ActiveWindow.<strong class="bterm">Index</strong> &gt; Projects(ActiveProject.<strong class="bterm">Index</strong> + 1).Windows.Count Then
    MsgBox("No equivalent window in the next project")
' If everything's okay, switch to the window in the next project.
    Projects(ActiveProject.<strong class="bterm">Index</strong> + 1).Windows(ActiveWindow.<strong class="bterm">Index</strong>).Activate
End If

End Sub

See Also