Windows API を使用してトップに戻すことはできますか? これは、Excelで実行してメモ帳を一番上に表示するとうまくいくので、うまくいくはずです。FindWindow 呼び出しでウィンドウの名前を置き換える必要があります。
注: いくつかのフラグの組み合わせを間違えると、おかしな動作をするので、注意が必要です。
Public Declare Function FindWindow Lib "user32" _
Alias "FindWindowA" ( _
ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Declare Function SetWindowPos Lib "user32.dll" (ByVal hwnd As _
Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As _
Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
'Either the handle of the window to position this window behind, or exactly one of the following flags stating where in the
'Z-order to put the window:
Private Const HWND_BOTTOM = 1 'Put the window at the bottom of the Z-order.
Private Const HWND_NOTOPMOST = -2 'Put the window below all topmost windows and above all non-topmost windows.
Private Const HWND_TOP = 0 'Put the window at the top of the Z-order.
Private Const HWND_TOPMOST = -1 'Make the window topmost (above all other windows) permanently.
'x: The x coordinate of where to put the upper-left corner of the window.
'y: The y coordinate of where to put the upper-left corner of the window.
'cx: The x coordinate of where to put the lower-right corner of the window.
'cy: The y coordinate of where to put the lower-right corner of the window.
'Flags: Zero or more of the following flags stating how to move the window:
Private Const SWP_DRAWFRAME = &H20 'Same as SWP_FRAMECHANGED.
Private Const SWP_FRAMECHANGED = &H20 'Fully redraw the window in its new position.
Private Const SWP_HIDEWINDOW = &H80 'Hide the window from the screen.
Private Const SWP_NOACTIVATE = &H10 'Do not make the window active after moving it unless it was already the active window.
Private Const SWP_NOCOPYBITS = &H100 'Do not redraw anything drawn on the window after it is moved.
Private Const SWP_NOMOVE = &H2 'Do not move the window.
Private Const SWP_NOSIZE = &H1 'Do not resize the window.
Private Const SWP_NOREDRAW = &H8 'Do not remove the image of the window in its former position, effectively leaving a ghost image on the screen.
Private Const SWP_NOZORDER = &H4 'Do not change the window's position in the Z-order.
Private Const SWP_SHOWWINDOW = &H40 'Show the window if it is hidden.
Sub ShowWindow()
Dim hwnd As Long 'handle to get the window
Dim flags As Long ' the flags specifying how to move the window
Dim retval As Long ' return value
hwnd = FindWindow(vbNullString, "Untitled - Notepad")
flags = SWP_NOSIZE Or SWP_DRAWFRAME
retval = SetWindowPos(hwnd, HWND_TOP, 0, 0, 1, 1, flags) ' move the window
End Sub