Auto Error Error Error in Internet Explorer Excel VBA Object
I've been working with some code for a while and literally, all of a sudden, it broke me. Here is the error message I receive:
Run-time error '-2147467259 (80004005)' Automation error Unspecified error
the line of code is specific to instantiating the InternetExporer object, except that I did nothing to change the code. It just stopped working. What could be the problem?
This happened before and I fixed it by explicitly calling the library (MSHTML for HTMLBsaeObject before), except that I only use object when variable names
Public Sub ValueLineResearch() setUp Dim myFund As String loginN = Sheets("Logins").Range("B2").Text pwStr = Sheets("Logins").Range("B3").Text 'Get the site iEx.Navigate "https://jump.valueline.com/login.aspx" iEx.Visible = True Call waitForIE 'Need to login now don't we iEx.Document.forms("aspnetForm").Item("ctl00_ContentPlaceHolder_LoginControl_txtUserID").Value = loginN iEx.Document.forms("aspnetForm").Item("ctl00_ContentPlaceHolder_LoginControl_txtUserPw").Value = pwStr iEx.Document.forms("aspnetForm").Item("ctl00_ContentPlaceHolder_LoginControl_btnLogin").Click Call waitForIE Application.Wait DateAdd("s", 6, Now) iEx.Navigate "https://research.valueline.com/secure/research#sec=library" Call waitForIE For Each el1 In iEx.Document.getElementsByClassName("symbol-search textInput ui-autocomplete-input mod_search-symbols primary_symbol_search") el1.Value = fundToResearch Next Application.Wait DateAdd("s", 2, Now) iEx.Document.forms("quoteSearch").submit Call waitForIE Application.Wait DateAdd("s", 2, Now) iEx.Navigate "https://research.valueline.com/secure/research#list=recent&sec=company&sym=" & fundToResearch Call waitForIE 'store the Doc Set ieDoc = iEx.Document 'For linkItem = 0 To ieDoc.Links.Length - 1 ' 'Get the PDF ' If InStr(1, ieDoc.Links(linkItem).href, ".pdf", vbTextCompare) > 0 And InStr(1, ieDoc.Links(linkItem).href, "UserGuide", vbTextCompare) <= 0 Then ' ieDoc.Links(linkItem).Click ' iEx.Visible = True ' Exit For ' End If 'Next linkItem Set iEx = Nothing End Sub
And the sub setting is like this:
set iEx = CreateObject("InternetExplorer.Application") fundToResarch = LCase(InputBox("Please Enter a Fund"))
source to share
I had a similar problem getting an "Automation Error" instantiating InternetExplorer in a function that gets called multiple times. It works fine, but after a few crashes with an automation error. I found that I have multiple IE processes in memory, which means there is not enough installation to install the process from memory
objIE = Nothing
. The solution is to call the Exit method before setting objIE to Nothing.
objIE.Quit 'Put in a brief pause set objIE = Nothing
source to share
For others that end here with the same error ...
It can also be caused by referencing a property of an object
in the object
after exiting and inactive. Please note that this is not what is happening in the question. I was able to reproduce the error with code similar to this:
Dim ie As New InternetExplorer ie.Visible = True ie.Navigate "google.com" ie.Quit Set ie = Nothing If ie.Document Is Nothing Then 'Error thrown here MsgBox "Can't get here" End If
source to share