HTML/VBA Click event not firing

醉酒当歌 提交于 2019-12-06 11:35:29

问题


This is my first time posting a question on StackOverflow. Up until now I have been able to resolve most of my questions via VBA help forums.

My issue is pretty simple. I have an automated data pull in which I need to export data. I have been successful with this in the past, but this one is slightly different.

The HTML for the button I am trying to click to generate the export is this:

  <a id="ReportViewer1_ctl01_ctl05_ctl01" 
    style="font-family: Verdana; font-size: 8pt; color: Gray; text-decoration: none; 
    cursor: default;" href="#" title="Export"
 onmouseout="TextLinkReportViewer1_ctl01_ctl05_ctl01.OnLinkNormal();"
 onmouseover="TextLinkReportViewer1_ctl01_ctl05_ctl01.OnLinkHover();" 
    onclick="if (document.getElementById('ReportViewer1_ctl01_ctl05_ctl00').selectedIndex == 0) return false; 
    if (!ClientToolbarReportViewer1_ctl01.HandleClientSideExport()) __doPostBack('ReportViewer1$ctl01$ctl05$ctl01','');return false;">Export</a>

I have tried several ways to click to no avail.


回答1:


FireEvent is used to trigger the event attached to any element.

IE.document.getElementById("ReportViewer1_ctl01_ctl05_ctl01").click()
IE.document.getElementById("ReportViewer1_ctl01_ctl05_ctl01").FireEvent("onclick")



回答2:


IE.document.getElementById("ReportViewer1_ctl01_ctl05_ctl01").click()


来源:https://stackoverflow.com/questions/19140394/html-vba-click-event-not-firing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!