matthieu latour
New Member
- Joined
- Aug 7, 2013
- Messages
- 1
HI everybody,
I've seen in this forum and other, how to control IE browser with his window handle. I can't find a solution. Maybe could you help me in this case.
Message in this forum which looks the most to my problem is here : http://www.mrexcel.com/forum/excel-questions/276716-how-get-instance-window-handle.html
Here's the source code. I use Excel 2007 with VBA.
Private Declare Function FindWindowExA& Lib "User32" (ByVal hWnd1&, ByVal hWnd2&, ByVal lpsz1$, ByVal lpsz2$)
Private Declare Function IIDFromString Lib "ole32" _
(ByVal lpsz As Long, ByRef lpiid As GUID) As Long
Private Declare Function AccessibleObjectFromWindow Lib "oleacc" _
(ByVal hWnd As Long, ByVal dwId As Long, ByRef riid As GUID, _
ByRef ppvObject As Object) As Long
Private Const IID_IDispatch As String = "{00020400-0000-0000-C000-000000000046}"
Private Type GUID
Data1 As Long
Data2 As Integer
Data3 As Integer
Data4(7) As Byte
End Type
Public Function getIEByHandle(handle) As Object
Dim o As Object
Dim t As GUID
Dim IEApp As Object
WBsWnd = FindWindowExA(handle, 0&, "IEFrame", vbNullString)
If WBsWnd Then
If AccessibleObjectFromWindow(WBsWnd, OBJID_NATIVEOM, t, o) = S_OK Then 'If AccessibleObjectFromWindow(WBsWnd, OBJID_NATIVEOM, t, o) = S_OK Then
Set IEApp = o.Application
End If
End If
End Function
public sub test()
Call getIEByHandle(hWnd)
End Sub
Thank you very much !
I've seen in this forum and other, how to control IE browser with his window handle. I can't find a solution. Maybe could you help me in this case.
Message in this forum which looks the most to my problem is here : http://www.mrexcel.com/forum/excel-questions/276716-how-get-instance-window-handle.html
Here's the source code. I use Excel 2007 with VBA.
Private Declare Function FindWindowExA& Lib "User32" (ByVal hWnd1&, ByVal hWnd2&, ByVal lpsz1$, ByVal lpsz2$)
Private Declare Function IIDFromString Lib "ole32" _
(ByVal lpsz As Long, ByRef lpiid As GUID) As Long
Private Declare Function AccessibleObjectFromWindow Lib "oleacc" _
(ByVal hWnd As Long, ByVal dwId As Long, ByRef riid As GUID, _
ByRef ppvObject As Object) As Long
Private Const IID_IDispatch As String = "{00020400-0000-0000-C000-000000000046}"
Private Type GUID
Data1 As Long
Data2 As Integer
Data3 As Integer
Data4(7) As Byte
End Type
Public Function getIEByHandle(handle) As Object
Dim o As Object
Dim t As GUID
Dim IEApp As Object
WBsWnd = FindWindowExA(handle, 0&, "IEFrame", vbNullString)
If WBsWnd Then
If AccessibleObjectFromWindow(WBsWnd, OBJID_NATIVEOM, t, o) = S_OK Then 'If AccessibleObjectFromWindow(WBsWnd, OBJID_NATIVEOM, t, o) = S_OK Then
Set IEApp = o.Application
End If
End If
End Function
public sub test()
Call getIEByHandle(hWnd)
End Sub
Thank you very much !
Last edited: