|
こんなマクロを標準モジュールの先頭から入れて、試してみて下さい。
Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Declare Function SetWindowPos Lib "user32" (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
Dim MyFlg As Boolean
Const TUNENI_TEMAE_SET = -1 '常に手前にセット
Const KAIJYO = -2 '解除
Const HYOUZI_SURU = &H40
Const NO_SIZE = &H1
Const NO_MOVE = &H2
Sub TEST_TEMAE()
Dim hWnd As Long, Ret As Long
Dim Ans As Integer
hWnd = FindWindow("XLMAIN", Application.Caption)
If MyFlg Then
Ans = MsgBox("常に手前表示を解除しますか", 36)
If Ans = 6 Then
Ret = SetWindowPos(hWnd, KAIJYO, 0, 0, 0, 0, _
HYOUZI_SURU Or NO_MOVE Or NO_SIZE)
MyFlg = False
End If
Else
Ans = MsgBox("常に手前に表示しますか", 36)
If Ans = 6 Then
Ret = SetWindowPos(hWnd, TUNENI_TEMAE_SET, 0, _
0, 0, 0, HYOUZI_SURU Or NO_MOVE Or NO_SIZE)
MyFlg = True
End If
End If
End Sub
|
|