excel让用户窗体桌面置顶?

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
Sub 打开首页()
Call 窗口总在最前面
UserForm1.Show
End Sub

大神帮我看看,这个打开首页的话是excel工作簿的置顶,,我想要让UserForm1桌面置顶应该怎么改写。麻烦帮我看看谢谢

    findwindow找到userform1的句柄,使用setgroundwindow设置该句柄窗口最前;

    尝试使用userform1.focus

温馨提示:答案为网友推荐,仅供参考
相似回答