VBA 点击事件 Internet Explorer 不起作用



我是 VBA 的新手,我正在尝试自动化 Web Explorer 导航,但有很多困难。我编写了一个脚本,用于导航到网页并搜索代码。结果是一个表格("DR-表单元格富表-单元格"),其中一行包含搜索的项目("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"href按钮(是搜索的项目)并执行播放另一个表的javascript功能。

这是我的代码:

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 

结束子

我可以找到该项目,但我无法执行代码以按下按钮。我使用的是IE 11。

感谢您的耐心等待!.

这应该有效:

ie.Document.getElementById("formRicercaPdr:pdrTable:0:j_id13‌​4"). _
     getElementsByTag‌​Name("a")(0).Click  

最新更新