VB.net InternetExplorer HtmlDocument

VB.net InternetExplorer HtmlDocument,vb.net,Vb.net,有人能帮我吗?我是VB.net新手,尝试编写一个非常简单的代码来操作网站。然而,我不断地 发生“System.InvalidCastException”类型的未处理异常 在Defer All.exe中…无法强制转换类型为的COM对象 “System.\uuuComObject”到接口类型“mshtml.HTMLDocument”。此 操作失败,因为COM组件上的QueryInterface调用失败 用于与IID’的接口 改变 Dim IE As InternetExplorer Dim HTML

有人能帮我吗?我是VB.net新手,尝试编写一个非常简单的代码来操作网站。然而,我不断地

发生“System.InvalidCastException”类型的未处理异常 在Defer All.exe中…无法强制转换类型为的COM对象 “System.\uuuComObject”到接口类型“mshtml.HTMLDocument”。此 操作失败,因为COM组件上的QueryInterface调用失败 用于与IID’的接口

改变

Dim IE As InternetExplorer
Dim HTMLDoc As HtmlDocument
'                    ^---------------------------this thing to,
                                                 mshtml.IHTMLDocument
Dim oHTML_Element As mshtml.IHTMLElement
改变

Dim IE As InternetExplorer
Dim HTMLDoc As HtmlDocument
'                    ^---------------------------this thing to,
                                                 mshtml.IHTMLDocument
Dim oHTML_Element As mshtml.IHTMLElement

您必须等待浏览器实际导航到该页面。在此之前,Document属性可能是null,或者其他不确定的。您想处理DocumentCompleted事件。谢谢Dan-o。对不起,我编辑了我的帖子。我确实等到一切都完成了。IE.文档似乎是一个com.对象,无法转换为HTMLDocument。我不知道为什么它不起作用。它在VBA中工作。您必须等待浏览器实际导航到该页面。在此之前,Document属性可能是null,或者其他不确定的。您想处理DocumentCompleted事件。谢谢Dan-o。对不起,我编辑了我的帖子。我确实等到一切都完成了。IE.文档似乎是一个com.对象,无法转换为HTMLDocument。我不知道为什么它不起作用。它在VBA中工作。