获取HRESULT:0x800A01B6从InternetExplorerMedium网站获取元素时出现异常

时间:2014-09-25 15:46:04

标签: vb.net vba hresult

我试图在VB.net上创建一些打开网站并登录的代码,之后运行报告。当我尝试从网站上获取任何内容时,一切都运行正常,但是在OnClick属性中有这条指令的那些="返回oamSubmitForm(' inputParamView:paramForm',' ; inputParamView:paramForm:_idJsp106');"

基本上,如果您看到以下代码,您会看到我单击某些CheckBox并且它工作正常,但是当我检索按钮时,它没有输入输入,它实际上有链接我在调试时使用whatc的网站。

这是我的代码(我跳过了登录部分):

Private Sub open Page()
ieb = New SHDocVw.InternetExplorerMedium()
ieb.Navigate("http://example.example/qptheme2/pages/index.faces")
ieb.visible = True
ieb.Silent = True

While Not (ieb.ReadyState = WebBrowserReadyState.Complete)
    Application.DoEvents()
End While

If v.checked = False Then
    v.Click()
End If

v = ie.Document.GetElementById("inputParamView:paramForm:inputParametertuesday")

If v.checked = False Then
    v.Click()
End If

v = ie.Document.GetElementById("inputParamView:paramForm:_idJsp106")

v.Click() '<-- IT FAILS HERE Exception HRESULT: 0x800A01B6

如果我查看手表,则会显示mshtml.HTMLAnchorElementClass {http://example.example/qpreport/savedpages/savedReports.faces#} 如果我从页面检查源代码,这是我试图获得的元素:

<a id="inputParamView:paramForm:_idJsp106" onclick="return
oamSubmitForm('inputParamView:paramForm','inputParamView:paramForm:_idJsp106');" href="#"

我不知道它是否与OnClick属性有关。

我将非常感谢您尝试解决此问题的任何帮助。

1 个答案:

答案 0 :(得分:2)

我自己找到了解决方案。我只需将我检索的元素实例化为mshtml.HTMLAnchorElementClass 之后,我可以点击它。

Dim l As mshtml.HTMLAnchorElementClass = ieb.Document.GetElementById("inputParamView:paramForm:_idJsp106")
l.click()