我已经和一些代码一起工作了一段时间,但突然间它出现了问题。这是我收到的错误信息:
Run-time error '-2147467259 (80004005)'
Automation error
Unspecified error
这行代码是在实例化InternetExplorer对象时使用的,但我没有更改过代码。它突然停止工作了,可能是什么问题?
这种情况以前也发生过,我通过显式调用库(之前是MSHTML用于HTMLBsaeObject),但现在只是在变量命名时使用一个对象。
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
而设置子程序如下:
set iEx = CreateObject("InternetExplorer.Application")
fundToResarch = LCase(InputBox("Please Enter a Fund"))