【发布时间】:2017-10-31 12:05:14
【问题描述】:
我正在尝试通过 VBA excel 脚本单击网页上的按钮,但在使用以下代码时出现运行时错误:
objIE.document.getElementById("e-actions-commonmasthead-mail").Click
我试图从页面中获取的元素使用以下 HTML 列出:
<td id="e-actions-commonmasthead-mail"
class="s-cell-center s-toolbarcell-left s-toolbar-text s-toolbarcell-selected"
title="Mail" toolbarside="left" toolbarindex="0"
com_ibm_dwa_ui_toolbar_overflowed="false"
onmouseover="AAA.DSq.EKc.prototype.EYl['e-actions-commonmasthead:Ebx'].EEu(event, this);"
onmouseout="AAA.DSq.EKc.prototype.EYl['e-actions-commonmasthead:Ebx'].EEu(event, this);"
onclick="AAA.DSq.ELU(event, 'e-actions-commonmasthead', 'Gqj', {area:'mail'});"
unselectable="on" style="-moz-box-sizing:border-box;-webkit-user-select:none;">
<img align="center" border="0" width="16" height="16"
id="e-actions-commonmasthead-mail-icon"
class="s-toolbaricon-notext"
src="/iNotes/Forms9.nsf/transparent.gif?OpenFileResource&MX&TS=20160816T154745,21Z"
xoffset="" yoffset=""
style="background-image: url("/iNotes/Forms9.nsf/sprite_masthead.png?OpenFileResource&MX&TS=20160816T154745,21Z");
background-position: -17px 0px;">
</td>
我已经尝试过 Click 和 FireEvent "onclick",但它们给了我运行时错误。
【问题讨论】:
-
你遇到了什么错误?
-
我收到运行时错误“424”,需要对象。
-
检查您发布的代码行中的每个对象,看看哪个是
Nothing。发布更多代码会很有用。
标签: javascript html vba