讓excel工作表保持最前的方法:
1.新建一個工作簿,按Alt+F11,開啟VBA編輯器。
2.單擊選單“插入→模組”,在右側的程式碼視窗中貼上下列程式碼:
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
Const HWND_TOPMOST = -1
Const HWND_NOTOPMOST = -2
Const SWP_NOSIZE = &H1
Const SWP_NOMOVE = &H2
Sub 視窗總在最前面()
SetWindowPos Application.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE
End Sub
Sub 恢復()
SetWindowPos Application.hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE
關閉VBA編輯器。
4.選擇宏名“恢復”並執行將取消視窗總在最前面的設定。
讓excel工作表保持最前的方法:
1.新建一個工作簿,按Alt+F11,開啟VBA編輯器。
2.單擊選單“插入→模組”,在右側的程式碼視窗中貼上下列程式碼:
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
Const HWND_TOPMOST = -1
Const HWND_NOTOPMOST = -2
Const SWP_NOSIZE = &H1
Const SWP_NOMOVE = &H2
Sub 視窗總在最前面()
SetWindowPos Application.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE
End Sub
Sub 恢復()
SetWindowPos Application.hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE
End Sub
關閉VBA編輯器。
4.選擇宏名“恢復”並執行將取消視窗總在最前面的設定。