Share via


Application.WindowActivate Method

Project Developer Reference

Activates a window.

Syntax

expression.WindowActivate(WindowName, DialogID, TopPane)

expression   A variable that represents an Application object.

Parameters

Name Required/Optional Data Type Description
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 2007 should activate the upper pane. The default value is True.

Return Value
Boolean

Example

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

Visual Basic for Applications
  ActivateBookmarkedWindow

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

Visual Basic for Applications
  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
    <strong class="bterm">WindowActivate</strong> (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

See Also