Método Application.WindowActivate (Project)

Ativa uma janela.

Sintaxe

expression. WindowActivate( _WindowName_, _DialogID_, _TopPane_ )

expressão Uma variável que representa um Aplicativo objeto.

Parâmetros

Nome Obrigatório/Opcional Tipo de dados Descrição
WindowName Opcional String O nome da janela a ser ativada. O nome de uma janela é o texto exato que aparece na barra de título da janela. O padrão é o nome da janela ativa.
DialogID Opcional Long Uma constante especificando a caixa de diálogo para ativar. Pode ser a seguinte constante PjDialog: pjResourceAssignment.
TopPane Opcional Boolean True se Project deve ativar o painel superior. O valor padrão é True.

Valor de retorno

Boolean

Exemplo

Os exemplos a seguir permitem que o usuário especifique e ativar uma janela "hot". Se você atribuir a macro ActivateBookmarkedWindow a uma tecla de atalho, você pode pressionar essa tecla para ativar rapidamente a janela com indicado.

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

Suporte e comentários

Tem dúvidas ou quer enviar comentários sobre o VBA para Office ou sobre esta documentação? Confira Suporte e comentários sobre o VBA para Office a fim de obter orientação sobre as maneiras pelas quais você pode receber suporte e fornecer comentários.