iwebbrowser2对象的方法文档失败

时间:2019-07-18 09:43:02

标签: vba syntax-error

当我通过代码启动站点时,在变量“ 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

感谢您帮助我看到我的错误

1 个答案:

答案 0 :(得分:0)

此类错误的可能原因之一是安全限制。尝试将infra.ftgroup添加到IE设置中的“受信任的站点”区域:

internet properties

trusted sites

也尝试在兼容性视图中打开网站:

compatibility view

compatibility view settings

并在开发人员工具 F12 -“模拟”标签上使用模式:

ie modes