Share via


WindowActivate Method

Activates a window.

Syntax

expression**.WindowActivate(WindowName, DialogID, TopPane)**

*expression   *     Optional. An expression that returns an Application object.

WindowName    Optional String. The name of the window to activate. The name of a window is the exact text that appears in the title bar of the window. The default is the name of the active window.

DialogID    Optional Long. A constant specifying the dialog box to activate. Can be the following PjDialog constant: pjResourceAssignment.

TopPane    Optional Boolean. True if Microsoft Office Project 2003 should activate the upper pane. The default value is True.

Example

The following examples allow the user to specify and activate a "hot" window. If you assign the

ActivateBookmarkedWindow

procedure to a shortcut key, you can press that key to quickly activate the bookmarked window.

Public BookmarkedWindowName As String  ' The name of the current bookmarked window

Sub ActivateBookmarkedWindow()

    Dim IsOpen As Boolean   ' Whether or not the current bookmarked window is open
    Dim I As Long           ' Index for For...Next loop
    
    IsOpen = False          ' Assume the bookmarked window is not open.
    
    For I = 1 To Windows.Count  ' Look for the current bookmarked window.
        If LCase(Windows(I).Caption) = LCase(BookmarkedWindowName) Then
            IsOpen = True
            Exit For
        End If
    Next I

    ' If the current bookmarked window is not open or defined, then run
    ' the ChangeBookmarkedWindow procedure.
    If Len(BookmarkedWindowName) = 0 Or Not IsOpen Then
        MsgBox ("The current bookmarked window is not open or has not been defined.")
        ChangeBookmarkedWindowName
    ' If the bookmarked window is open, activate it.
    Else
        WindowActivate (BookmarkedWindowName)
    End If
    
End Sub

Sub ChangeBookmarkedWindowName()

    Dim Entry As String     ' The text entered by the user
    
    Entry = InputBox$("Enter the name of the bookmarked window.")

    ' If the user chooses Cancel, then exit the Sub procedure.
    If Entry = Empty Then Exit Sub

    ' Otherwise, set the name of the bookmarked window and then activate it.
    BookmarkedWindowName = Entry
    ActivateBookmarkedWindow
    
End Sub

Applies to | Application Object

See Also | WindowArrangeAll Method | WindowDeactivate Event | WindowHide Method | WindowMoreWindows Method | WindowNewWindow Method | WindowNext Method | WindowPrev Method | WindowUnhide Method