Hello folks
I am struggling to use events with IE automation from an Excel workbook, to feed some data from a web server into Excel.
The queried page takes very long, and I would like the user to initiate the query with IE to obtain the data, then once the web page is complete, return control to my Excel book to fetch the data and perform some post-processing.
I first started with an IE object with :
The problem is, the loop will hold Excel waiting until the page is ready, and I cannot use Excel as long as the web query runs.
To perform asynchronously, I started investigating the event handlers, which I am not familiar with
I tried the following code in ThisWorkbook :
However it seems the event DocumentComplete will never fire??
Any idea what I am doing wrong here ?
Same applies with IE.Navigate2, and with a simple InternetExplorer object (without SHDocVw prefix)
I am running Windows 7 SP1 and Office 2010
References to "Microsoft Internet Controls" & "HTML Object Library" are activated
Thanks in advance
I am struggling to use events with IE automation from an Excel workbook, to feed some data from a web server into Excel.
The queried page takes very long, and I would like the user to initiate the query with IE to obtain the data, then once the web page is complete, return control to my Excel book to fetch the data and perform some post-processing.
I first started with an IE object with :
Code:
Do Until .readyState = 4
Application.Wait (Now + TimeValue("00:00:01"))
DoEvents
Loop
To perform asynchronously, I started investigating the event handlers, which I am not familiar with
I tried the following code in ThisWorkbook :
Code:
Private WithEvents IE As SHDocVw.InternetExplorer
Public Sub invokeIE()
Set IE = New SHDocVw.InternetExplorer
IE.Visible = True
IE.Navigate "http://www.google.com"
End Sub
Private Sub IE_DocumentComplete(ByVal pDisp As Object, URL As Variant)
MsgBox "Document complete" & vbCrLf & URL
End Sub
However it seems the event DocumentComplete will never fire??
Any idea what I am doing wrong here ?
Same applies with IE.Navigate2, and with a simple InternetExplorer object (without SHDocVw prefix)
I am running Windows 7 SP1 and Office 2010
References to "Microsoft Internet Controls" & "HTML Object Library" are activated
Thanks in advance