Método Application.WindowActivate (Project)
Activa una ventana.
Sintaxis
expresión. WindowActivate
( _WindowName_
, _DialogID_
, _TopPane_
)
expresión Variable que representa un objeto Application.
Parámetros
Nombre | Obligatorio/opcional | Tipo de datos | Descripción |
---|---|---|---|
WindowName | Opcional | String | Nombre de la ventana que se va a activar. El nombre de una ventana es el texto exacto que aparece en la barra de título de la ventana. El valor predeterminado es el nombre de la ventana activa. |
DialogID | Opcional | Long | Constante que especifica el cuadro de diálogo para activar. Puede ser la siguiente constante de PjDialog: pjResourceAssignment. |
TopPane | Opcional | Boolean | True si Project debe activar el panel superior. El valor predeterminado es True. |
Valor devuelto
Boolean
Ejemplo:
Los siguientes ejemplos permiten al usuario especificar y activar una ventana "activa". Si asigna la macro ActivateBookmarkedWindow a una tecla de método abreviado, puede presionar esa tecla para activar rápidamente la ventana marcador.
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
Soporte técnico y comentarios
¿Tiene preguntas o comentarios sobre VBA para Office o esta documentación? Vea Soporte técnico y comentarios sobre VBA para Office para obtener ayuda sobre las formas en las que puede recibir soporte técnico y enviar comentarios.