Application.WindowActivate-Methode (Project)

Aktiviert ein Fenster.

Syntax

Ausdruck. WindowActivate( _WindowName_, _DialogID_, _TopPane_ )

expression Eine Variable, die ein Application-Objekt darstellt.

Parameter

Name Erforderlich/Optional Datentyp Beschreibung
WindowName Optional String Der Name des zu aktivierenden Fensters. Der Name eines Fensters ist der Text, der in der Titelleiste des Fensters angezeigt wird. Der Standardwert ist der Name des aktiven Fensters.
DialogID Optional Long Eine Konstante, die das zu aktivierende Dialogfeld angeben. Kann die folgende PjDialog -Konstante sein: PjResourceAssignment.
TopPane Optional Boolean True, wenn Project den oberen Bereich aktivieren sollten. Der Standardwert ist True.

Rückgabewert

Boolean

Beispiel

In den folgenden Beispielen können der Benutzer angeben, und Aktivieren eines Fensters "hot". Wenn Sie das Makro ActivateBookmarkedWindow eine Tastenkombination zuweisen, können Sie schnell das mit einer Textmarke versehenen Fenster aktivieren, drücken.

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 und Feedback

Haben Sie Fragen oder Feedback zu Office VBA oder zu dieser Dokumentation? Unter Office VBA-Support und Feedback finden Sie Hilfestellung zu den Möglichkeiten, wie Sie Support erhalten und Feedback abgeben können.