VBA onclick事件Internet Explorer无法正常工作
我是新的VBA,我试图自动化的Web浏览器导航,但许多难题。 我编写了一个导航到网页并search代码的脚本。 结果是一个表格(“dr-table-cell rich-table-cell”),其中一行包含search到的项目(“02090000062571”),显示为另一页面的链接。 这里的表的代码:
<td class="dr-table-cell rich-table-cell" id="formRicercaPdr:pdrTable:0:j_id134"> <a onclick="if(typeof jsfcljs == 'function'){jsfcljs(document.forms['formRicercaPdr'],'formRicercaPdr:pdrTable:0:j_id136,formRicercaPdr:pdrTable:0:j_id136','');}return false" href="#">02090000062571</a> </td>
我的问题是点击“02090000062571”hrefbutton(是search的项目),并执行diplayed另一个表的javascriptfunction。
在这里我的代码:
Sub TriggerDivClick() Dim ie As SHDocVw.InternetExplorer Dim doc As MSHTML.HTMLDocument Dim div As HTMLDivElement Dim url As String url = "some URL" Set ie = New SHDocVw.InternetExplorer ie.Visible = True ie.Navigate url While ie.Busy Or ie.ReadyState <> READYSTATE_COMPLETE DoEvents Wend Set pdr_button = ie.Document.getElementsByClassName("dr-table-cell rich-table-cell") For Each a In pdr_button 'here comes the problems a.Item(0).FireEvent ("click()") Next a
结束小组
我可以find该项目,但我不能执行代码,以便按下button。 我正在使用IE 11。
谢谢你的耐心!。
这应该工作:
ie.Document.getElementById("formRicercaPdr:pdrTable:0:j_id134"). _ getElementsByTagName("a")(0).Click