I'm trying to automate a form submission in Excel for work, and In have trouble with the basics. I keep getting the error message:
"Method 'Document' of object 'IWebBrowser2' failed"
With the code as is, and if I include the Or part in the waiting check, I get the error
"Automation Error The object invoked has disconnected from its clients."
I'm not sure what to do here, I've searched all over for solutions. This code is intended to eventually do more than this, but it keeps failing on the first try to getElementsByTagName
.
Sub GoToWebsiteTest()
Dim appIE As Object 'Internet Explorer
Set appIE = Nothing
Dim objElement As Object
Dim objCollection As Object
If appIE Is Nothing Then Set appIE = CreateObject("InternetExplorer.Application")
sURL = *link*
With appIE
.Visible = True
.Navigate sURL
End With
Do While appIE.Busy ' Or appIE.ReadyState <> 4
DoEvents
Loop
Set objCollection = appIE.Document.getElementsByTagName("input")
Set appIE = Nothing
End Sub
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…