
#If VBA7 And Win64 ThenPrivate xlMain As LongPtrPrivate Excel2 As LongPtrPrivate StatusBar As LongPtr#ElsePrivate xlMain As LongPrivate Excel2 As LongPrivate StatusBar As Long#End If#If VBA7 And Win64 ThenPrivate Declare PtrSafe Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As LongPtr, ByVal hWnd2 As LongPtr, ByVal lpsz1 As String, ByVal lpsz2 As String) As LongPtr#ElsePrivate Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long#End IfPublic Sub GetStatusBarHwnd()xlMain = Application.HwndExcel2 = FindWindowEx(xlMain, Nuptr, "EXCEL2", vbNullString)StatusBar = FindWindowEx(Excel2, Nuptr, "MsoCommandBar", vbNullString)MsgBox "已获取到状态栏的句柄:" & StatusBar & "。", vbInformation, "LELEDY"End Sub
https://pan.baidu.com/s/1iTzn_Nda1aGkh0JwyxYOIA
提取码通过关键词在公众号内获取👇
