如何在VBA/VBScript中执行onclick事件 [英] How to do onclick event in VBA/VBScript

查看:228
本文介绍了如何在VBA/VBScript中执行onclick事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<td class="highlightTab" id="tabnew" style="background-color: red; color: yellow;" onmouseover="setBgColor('tabnew')" onmouseout="setHighOrgBgColor('tabnew','highlightTab')">
<a class="highlightTabLabel" onclick="parent.MainFrame.request('ref_back','')" href="Javascript:void(0)">

我仍在尝试通过网页学习excel自动化.我正在尝试使用FireEvent强制onclick(同时使用click和fireevent,但都无法正常工作atm),但我无法弄清楚:

I am still trying to learn excel automation with web pages. I am trying to force the onclick using FireEvent (using both click and fireevent, but neither are working atm) and I cannot figure this out:

.getElementById("tabnew").Click
.getElementById("tabnew").FireEvent ("onclick")

有人有任何想法吗?我真的希望有更多有关html对象库的文档可以在VBScript/VBA中使用:(

Does anyone have any Ideas? I really wish there was more documentation on html object library for use in VBScript/VBA :(

推荐答案

以下是您要查找的内容:

Here's what you're looking for:

document.getElementById("tabnew").attachEvent"onclick",getref("onclick")

document.getElementById("tabnew").attachEvent "onclick",getref("onclick")

第一个参数是事件("onclick","onmouseover" ......,请参见: http://www.tutorialspoint.com/vbscript/vbscript_events.htm (事件列表的页面底部)第二个参数是子名称的getref.

First argument is the event ("onclick","onmouseover"... See: http://www.tutorialspoint.com/vbscript/vbscript_events.htm (very bottom of page for list of events)) Second argument is a getref of the name of your sub.

这篇关于如何在VBA/VBScript中执行onclick事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆