Windows2 Collection Object

Project Developer Reference

Represents a collection of windows in the application or project.

Bb209851.vs_note(en-us,office.12).gif  Note
The Windows2 collection is recommended instead of the Windows collection for all new development.

The Windows2 collection for the Application object contains all the windows in the application, whereas the Windows2 collection for the Project object contains only the windows in the specified project.

Using the Windows2 Collection

Use the Windows2 property to return a Windows2 collection.

Example
The following example cascades all the windows that are currently displayed in Microsoft Office Project 2007.

Visual Basic for Applications
  With Application.Windows2
    For I = 1 To .Count
        .Item(I).Activate
        .Item(I).Top = (I - 1) * 15
        .Item(I).Left = (I - 1) * 15
    Next I
End With

Use the WindowNewWindow method to create a new window and add it to the Windows2 collection.

Example
The following example creates a new window for the active project.

Visual Basic for Applications
  Application.WindowNewWindow

Using the Windows2 Object

Use Windows2(Index), where Index is the window index number or window caption, to return a single Window object.

Example
The following example maximizes the first window in the window list.

Visual Basic for Applications
  Application.Windows2(1).WindowState = pjMaximized

The window caption is the text shown in the title bar at the top of the window when the window is not maximized. The caption is also shown in the list of open files on the bottom of the Windows menu. Use the Caption property to set or return the window caption. Changing the window caption does not change the name of the project.

Example
The following example hides the window that contains the caption "Project1".

Visual Basic for Applications
  If Application.Windows2(1).Caption = "Project1" Then
    Application.Windows2(1).Visible = False
End If

Remarks

Development with the Microsoft .NET Framework or external components or applications that use Office Project 2007 must use the Windows2 object, not the Windows object. A Primary Interop Assembly (PIA) is required to interact correctly with the COM interface of Office Project 2007 if those components are to be signed. Microsoft Visual Studio .NET generates an interop assembly based on the type library if no PIA is present, but the components then cannot be signed with a digital certificate. The PIA is included with Office Project 2007.

See Also