Project) (Application.WindowActivate 方法
會啟動視窗。
語法
expression。 WindowActivate
( _WindowName_
, _DialogID_
, _TopPane_
)
expression 代表 Application 物件的變數。
參數
名稱 | 必要/選用 | 資料類型 | 描述 |
---|---|---|---|
WindowName | 選用 | String | 要啟動的視窗名稱。 視窗名稱就是顯示在視窗標題列中的實際文字。 預設值為使用中視窗的名稱。 |
DialogID | 選用 | Long | 指定要啟動對話方塊的常數。 可以是下列 PjDialog 常數: pjResourceAssignment 。 |
TopPane | 選用 | Boolean | True 是表示 如果專案應啟動上方窗格。 預設值為 True。 |
傳回值
布林值
範例
下列範例允許使用者指定並啟動 「 熱"視窗。 如果 ActivateBookmarkedWindow 巨集指派給的快速鍵,您可以按該機碼來快速啟用書籤的視窗。
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
支援和意見反應
有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應。