“如何激活JavaScript”;onclick";通过Excel VBA的事件?
我试图通过VBA excel脚本单击网页上的按钮,但使用以下代码时出现运行时错误:“如何激活JavaScript”;onclick";通过Excel VBA的事件?,javascript,html,vba,Javascript,Html,Vba,我试图通过VBA excel脚本单击网页上的按钮,但使用以下代码时出现运行时错误: objIE.document.getElementById("e-actions-commonmasthead-mail").Click Call objIE.document.parentWindow.execScript("AAA.DSq.ELU(event, 'e-actions-commonmasthead', 'Gqj', {area:'mail'})", "JavaScript") 我试图
objIE.document.getElementById("e-actions-commonmasthead-mail").Click
Call objIE.document.parentWindow.execScript("AAA.DSq.ELU(event, 'e-actions-commonmasthead', 'Gqj', {area:'mail'})", "JavaScript")
我试图从页面中获取的元素与以下HTML一起列出:
我尝试了Click和FireEvent“onclick”,但它们都给了我运行时错误。好的,我找到了答案。我需要通过以下代码手动调用onclick脚本:
objIE.document.getElementById("e-actions-commonmasthead-mail").Click
Call objIE.document.parentWindow.execScript("AAA.DSq.ELU(event, 'e-actions-commonmasthead', 'Gqj', {area:'mail'})", "JavaScript")
感谢所有的帮助和提示 您遇到了什么错误?我遇到了运行时错误“424”,需要对象。请检查您发布的代码行中的每个对象,以查看哪个对象是
Nothing
。多发布一些代码会很有用。