Application.WindowActivate method (Project)
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 Project 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 ActivateBookmarkedWindow macro 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
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.