Méthode Application.WindowActivate (Project)
Active une fenêtre.
Syntaxe
expression. WindowActivate
( _WindowName_
, _DialogID_
, _TopPane_
)
expressionUne variable qui représente un objetApplication.
Paramètres
Nom | Requis/Facultatif | Type de données | Description |
---|---|---|---|
WindowName | Facultatif | String | Nom de la fenêtre à activer. Il s’agit du texte exact qui apparaît dans la barre de titre de la fenêtre. La valeur par défaut est le nom de la fenêtre active. |
DialogID | Facultatif | Long | Constante qui spécifie la boîte de dialogue à activer. Il peut s’agir de la constante PjDialog suivante : pjResourceAssignment. |
TopPane | Facultatif | Boolean | True si Project doit activer le volet supérieur. La valeur par défaut est True. |
Valeur renvoyée
Boolean
Exemple
Les exemples suivants montrent comment permettre à l’utilisateur de spécifier et d’activer une fenêtre « réactive ». Si vous affectez la macro ActivateBookmarkedWindow à une touche de raccourci, vous pouvez appuyer sur cette touche pour activer rapidement la fenêtre avec signet.
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
Assistance et commentaires
Avez-vous des questions ou des commentaires sur Office VBA ou sur cette documentation ? Consultez la rubrique concernant l’assistance pour Office VBA et l’envoi de commentaires afin d’obtenir des instructions pour recevoir une assistance et envoyer vos commentaires.
Commentaires
https://aka.ms/ContentUserFeedback.
Bientôt disponible : Tout au long de 2024, nous allons supprimer progressivement GitHub Issues comme mécanisme de commentaires pour le contenu et le remplacer par un nouveau système de commentaires. Pour plus d’informations, consultezEnvoyer et afficher des commentaires pour