【问题标题】:'Busy' method of 'IUWebBrowser2' object failed'IUWebBrowser2' 对象的'Busy' 方法失败
【发布时间】:2019-11-27 07:48:21
【问题描述】:

当我通过我的代码启动网站时,在我的变量“oDoc”级别出现“对象 iwebbrowser2 的方法文档失败”类型的错误

Private Function CreerNavigateur(ByVal mails As String)
Dim IE As Object
Dim oDoc As Object
Dim Htable, maTable As Object
Dim text As String
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = False
IE.navigate "https://csrtool-ssl.sso.infra.ftgroup/csrtool_web/Bricks/pg/osuit/pages/identity/IdentityAccountAndUsers?type=emailAlias&value=" & mails & "&tab_main=AccountInfo"
While IE.Busy Or IE.ReadyState <> READYSTATE_COMPLETE: DoEvents: Wend
    Set oDoc = IE.Document
    Set Htable = oDoc.getElementsByTagName("div")(1)
   ' MsgBox Htable.innerhtml
    Set maTable = Htable.getElementsByTagName("span")
    'MsgBox maTable(0).href
    'myData = maTable(0).innertext
    'MsgBox (myData)
    IE.Quit
    'On libère les variables
    Set IE = Nothing
    Set oDoc = Nothing
End Function

谢谢你帮我看到我的错误

【问题讨论】:

  • 尝试使用最大化的ie窗口Dim ie As SHDocVw.InternetExplorer Set ie = New SHDocVw.InternetExplorer
  • 从工具=> 参考中添加“Microsoft Internet 控件”,然后尝试执行宏
  • 这样可以正常工作吗?你的问题解决了吗?
  • 它有效,但我在“当 IE.Busy 或 IE.ReadyState READYSTATE_COMPLETE: DoEvents: Wend”行看到此错误“运行时错误 -2147467259 ': 未指定的自动化错误”
  • 请不要在不同的帐户下发布重复的问题。 stackoverflow.com/questions/57091574/…

标签: vba web web-scraping


【解决方案1】:

形式化我的答案尝试最大化即窗口和更新的代码将是

Private Function CreerNavigateur(ByVal mails As String)
    Dim ie As SHDocVw.InternetExplorer
    Dim oDoc As Object
    Dim Htable, maTable As Object
    Dim text As String

    Set ie = New SHDocVw.InternetExplorer
    ie.Visible = False
    ie.navigate "https://csrtool-ssl.sso.infra.ftgroup/csrtool_web/Bricks/pg/osuit/pages/identity/IdentityAccountAndUsers?type=emailAlias&value=" & mails & "&tab_main=AccountInfo"

    While ie.Busy Or ie.ReadyState <> READYSTATE_COMPLETE: DoEvents: Wend

    Set oDoc = ie.Document
    Set Htable = oDoc.getElementsByTagName("div")(1)
    'MsgBox Htable.innerhtml
    Set maTable = Htable.getElementsByTagName("span")
    'MsgBox maTable(0).href
    'myData = maTable(0).innertext
    'MsgBox (myData)
    ie.Quit
    'On libère les variables
    Set ie = Nothing
    Set oDoc = Nothing
End Function

【讨论】:

  • 我在“While IE.Busy Or IE.ReadyState READYSTATE_COMPLETE: DoEvents: Wend”这一行看到了这个错误“运行时错误 -2147467259 ': 未指定的自动化错误”
  • 请试试上面提到的代码,这里我们使用的是IE而不是IE
  • 同样的错误“运行时错误'-2147467259':未指定的自动化错误”
  • 我没有回答我的问题
  • @ArmelKounou 将可见属性设置为 true 并查看网页是否打开,如果没有则检查兼容性视图
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-06-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多