Application.WindowActivate メソッド (Project)

ウィンドウをアクティブにします。

構文

WindowActivate( _WindowName_, _DialogID_, _TopPane_ )

expressionApplication オブジェクトを 表す変数。

パラメーター

名前 必須 / オプション データ型 説明
WindowName 省略可能 String アクティブにするウィンドウの名前を指定します。 ウィンドウの名前は、ウィンドウのタイトル バーに表示される文字列と一致する必要があります。 既定値はアクティブ ウィンドウの名前です。
DialogID 省略可能 長整数型 (Long) アクティブにする] ダイアログ ボックスを指定する定数です。 PjDialog 定数を次にすることができます: pjResourceAssignment です。
TopPane 省略可能 ブール型 (Boolean) True の 場合、プロジェクトには、上部のウィンドウがアクティブにする必要があります。 既定値は True です。

戻り値

ブール型 (Boolean)

次の例では、ユーザーを指定し、[高] のウィンドウをアクティブにするを使用できます。 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 のサポートおよびフィードバックを参照してください。