VBA API declarations. Bring window to front , regardless of application

前端 未结 2 807
你的背包
你的背包 2020-12-11 05:33

I am trying to bring and Excel window to the front of all applications running regardless.

Current code,

Private Declare Function SetForegroundWindow         


        
2条回答
  •  渐次进展
    2020-12-11 06:23

    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
    

提交回复
热议问题