简体   繁体   English

对象iwebbrowser2的方法文档失败

[英]method document of object iwebbrowser2 failed

I am getting this error "method document of object iwebbrowser2 failed".. Please look the code below. 我收到此错误“对象iwebbrowser2的方法文档失败”。。请查看下面的代码。

Sub getIE()
Dim sh As Object, oWin As Object, IE As Object

Set sh = CreateObject("Shell.Application")

For Each oWin In sh.Windows
    If TypeName(oWin.document) = "HTMLDocument" Then
        Set IE = oWin
        Exit For
    End If
Next

MsgBox IE.document.URL

End Sub

First make sure you have opened a site on Internet Explorer. 首先,请确保您已经在Internet Explorer上打开了一个站点。 Then run the code. 然后运行代码。 I did not get the error as yours but got object reference error. 我没有得到您的错误,但是得到了对象引用错误。 So, added a check when the object is nothing. 因此,在对象为空时添加了检查。

Sub getIE()
  Dim sh As Object, oWin As Object, IE As Object

  Set sh = CreateObject("Shell.Application")

  For Each oWin In sh.Windows
    If TypeName(oWin.document) = "HTMLDocument" Then
        Set IE = oWin
        Exit For
    End If
  Next

  If Not IE Is Nothing Then
    MsgBox IE.document.URL
  End If

End Sub

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 iwebbrowser2对象的方法文档失败 - the method document of the iwebbrowser2 object failed 对象'IWebBrowser2'的Excel VBA“方法'文档'失败” - Excel VBA “Method 'Document' of object 'IWebBrowser2' failed” object 'IWebBrowser2' 的方法文档在专用公司服务器上失败 - Method Document of object 'IWebBrowser2' failed on a dedicated company server VBA IE 选中并取消选中具有相同名称和不同值的复选框“object iwebbrowser2 的文档失败”错误 - VBA IE check and uncheck the checkbox with same-name and different-values "document of object iwebbrowser2 failed" error Excel VBA:在锁定屏幕的情况下运行 IE.ExecWB 12,2 返回“对象'IWebBrowser2'的方法'ExecWB'失败” - Excel VBA: running IE.ExecWB 12,2 with locked screen returns "Method 'ExecWB' of object 'IWebBrowser2' failed" 访问IWebBrowser2文档属性返回空 - Accessing the IWebBrowser2 Document property returns empty 更改选项卡时,MultiPage 上的 WebBrowser 失败并出现 object 'IWebBrowser2' 错误的“导航” - WebBrowser on MultiPage failing with a 'Navigate' of object 'IWebBrowser2' error when the tabs are changed 打开几个新标签页时,IWebBrowser2 :: Navigate2有时会冻结 - IWebBrowser2::Navigate2 occasionally freezes when opening several new tabs 对象的方法'Parent'失败 - Method 'Parent' of object failed 对象“_Application”的方法“VBE”失败 - Method 'VBE' of object '_Application' failed
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM