Table of contents
Collapse the table of content
Expand the table of content

Application.WindowActivate Method (Project)

office 365 dev account|Last Updated: 6/12/2017
1 Contributor

Activates a window.


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

expression A variable that represents an Application object.


NameRequired/OptionalData TypeDescription
WindowNameOptionalStringThe 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.
DialogIDOptionalLongA constant specifying the dialog box to activate. Can be the following PjDialog constant: pjResourceAssignment.
TopPaneOptionalBooleanTrue if Project should activate the upper pane. The default value is True.

Return Value



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.") 
 ' If the bookmarked window is open, activate it. 
 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 

End Sub
© 2018 Microsoft