'Busy' method of 'IUWebBrowser2' object failed

≯℡__Kan透↙ 提交于 2019-12-11 16:07:26

问题


When I launch the site via my code, there is an error of type "method document of object iwebbrowser2 failed " at the level of my variable "oDoc"

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

thank you for helping me to see my mistake


回答1:


formalizing my answer try maximized ie window and updated code will be

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


来源:https://stackoverflow.com/questions/57093430/busy-method-of-iuwebbrowser2-object-failed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!