Control IE with handle

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 !
 
Last edited:

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying

Forum statistics

Threads
1,215,758
Messages
6,126,718
Members
449,332
Latest member
nokoloina

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top