Long time fan of Mr. Excel, first time poster: I just migrated to Office 2010 and have run up against a slew of problems, mostly permissions and library reference problems that you get every time you upgrade, But this one problem is not going away easily:
While automating Internet Explorer through Excel VBA I keep getting errors because the object is disconnecting itself after the instruction to navigate to any URL. It is RunTime Errer 80010108, "The object invoked has disconnected from its clients."
Here is a very simple bit of code which I have been using successfully for years in earlier versions:
I don't know why this error is happening. I'm hoping someone else has seen it before and knows how to work around it. I found a few threads on that particular error itself, but none involving automation where another program was being controlled as an object.
Any help at all would be appreciated....
Thank you
John Richter
While automating Internet Explorer through Excel VBA I keep getting errors because the object is disconnecting itself after the instruction to navigate to any URL. It is RunTime Errer 80010108, "The object invoked has disconnected from its clients."
Here is a very simple bit of code which I have been using successfully for years in earlier versions:
Code:
Sub openIE()
Dim ie As InternetExplorer
Dim MyStr As String
Set ie = New InternetExplorer
'Search google for "VBA Excel Automation"
ie.Navigate2 "http://www.google.com/search?q=vba+excel+automation"
[COLOR=Red]' After IE opens and navigates to the above URL it disconnects itself
' and can not be referenced as the object "ie" anymore. the next line of
' code that references the object will trigger the error
' I tried using a wait command below instead of the do loop to wait for the
' page to finish loading, but then the next reference to the object
' will trigger the error anyway..[/COLOR]
'Loop unitl ie page is fully loaded
Do Until ie.readyState = 4
DoEvents
Loop
'This wait was added to isolate the exact point when the ie object was disconneecting
Application.Wait Time + TimeSerial(0, 0, 10)
'return text from google page
MyStr = ie.document.body.innerText
Sheet3.Range("A2") = MyStr
Set ie = Nothing
End Sub
Any help at all would be appreciated....
Thank you
John Richter