VBA API声明.不管应用如何,都将窗口置于最前面 [英] VBA API declarations. Bring window to front , regardless of application
本文介绍了VBA API声明.不管应用如何,都将窗口置于最前面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图将Excel窗口置于所有正在运行的应用程序的最前面.
I am trying to bring and Excel window to the front of all applications running regardless.
当前代码,
Private Declare Function SetForegroundWindow _
Lib "user32" _
(ByVal hWnd As Long) As Long
Public Sub Bring_to_front()
SetForegroundWindow wb.Application.hWnd
End Sub
Sub Test()
Set wb = Workbooks("MyWorkBook.xlxs")
call Bring_to_front
End Sub
此刻什么也没发生.
推荐答案
在进行了更多研究之后,找到了我试图做的事情的答案.
Found the answer to what I as trying to do after a bit more research.
这会将您指定的工作表放到最前面.
This will bring the worksheet you specify to the front.
Public Declare Function SetForegroundWindow _
Lib "user32" (ByVal hwnd As Long) As Long
Public Sub Bring_to_front()
Dim setFocus As Long
ThisWorkbook.Worksheets("Sheet1").Activate
setfocus = SetForegroundWindow(Application.hwnd)
End Sub
这篇关于VBA API声明.不管应用如何,都将窗口置于最前面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文