(1) 掛API
Private Declare Function FindWindow Lib "USER32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private 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
Sub AlwaysOnTop(最上層 As Boolean)
On Error Resume Next
h = Excel.Application.hwnd
If Err Then
h = FindWindow("XLMAIN", "Microsoft Excel - " & ThisWorkbook.Name)
End If
On Error GoTo 0
k = IIf(最上層, -1, -2)
Call SetWindowPos(h, k, 0, 0, 0, 0, 3)
End Sub作者: samsung2888 時間: 2015-4-24 22:23