VBA按钮点击进入Excel表,如何使Excel显示在最前面?
发布网友
发布时间:2022-04-20 10:51
我来回答
共2个回答
热心网友
时间:2023-10-05 05:08
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
Private Const HWND_TOP& = 0
Private Const HWND_BOTTOM& = 1
Private Const HWND_TOPMOST& = -1
Private Const HWND_NOTOPMOST& = -2
' 将窗口置于列表顶部,并位于任何最顶部窗口的前面
Private Const SWP_NOSIZE& = &H1
' 保持窗口大小
Private Const SWP_NOMOVE& = &H2
' 保持窗口位置
Private Sub TOPMOST()
' 将窗口设为总在最前
SetWindowPos Application.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
End Sub
Private Sub NOTOPMOST()
' 取消窗口总在最前
SetWindowPos Application.hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
End Sub
热心网友
时间:2023-10-05 05:08
如果总保持住前端,那你的窗体用起来岂不是很麻烦。
userform1.Show 0 '无模式状态,可以在窗体打开的同时,编辑excel。