“点击"使用VBA的javascript按钮

编程入门 行业动态 更新时间:2024-10-25 11:33:13
本文介绍了“点击"使用VBA的javascript按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

无休止的谷歌搜索和许多解决方案似乎无济于事.我不断收到无穷无尽的各种错误,除非找到让代码等待四秒钟(而我用鼠标手动单击它)的代码,否则找不到单击该按钮的优雅方法.

endless googling and lots of solutions haven't seemed to help. I keep getting endless errors of different kinds, and just can't find an elegant way of clicking this button unless I get the code to wait for four seconds while I click it manually with my mouse.

它可以在其他按钮上使用,但是如果这里的问题是嵌套的doPostBack和其中的许多''(从"代替),那么我在工作吗?

It works on other buttons, but I'm working if the problem here is the nested doPostBack and the many '' (substituted from "") in it?

下面的代码(我已经删除了不相关的部分)

Code below (I've trimmed out irrelevant sections)

VBA代码:

Sub IE_Clicks() Dim shellWins As ShellWindows Dim IE As InternetExplorer Set shellWins = New ShellWindows If shellWins.Count > 0 Then ' Get IE Set IE = shellWins.Item(0) IE.Visible = True Else ' Create IE Set IE = New InternetExplorer IE.Visible = True End If IE.Navigate ("[URL]") Do While (IE.Busy Or IE.READYSTATE <> READYSTATE.READYSTATE_COMPLETE) DoEvents Loop Call IE.document.parentWindow.execScript("WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions('ctl00$cphMain$btnAddTab', '', true, '', '', false, false))", "JavaScript") Set IE = Nothing End Sub

HTML代码:

<input type="submit" name="ctl00$cphMain$btnAddTab" value="Add New" onclick="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;ctl00$cphMain$btnAddTab&quot;, &quot;&quot;, true, &quot;&quot;, &quot;&quot;, false, false))" id="ctl00_cphMain_btnAddTab" class="ActionButton">

JavaScript:

JavaScript:

<script type="text/javascript"> //<![CDATA[ var theForm = document.forms['aspnetForm']; if (!theForm) { theForm = document.aspnetForm; } function __doPostBack(eventTarget, eventArgument) { if (!theForm.onsubmit || (theForm.onsubmit() != false)) { theForm.__EVENTTARGET.value = eventTarget; theForm.__EVENTARGUMENT.value = eventArgument; theForm.submit(); } } //]]> </script>

使我能够单击此按钮的东西真是太神奇了.

Something that would enable me to click this button would be amazing.

推荐答案

这应该有效:

IE.document.getElementById("ctl00_cphMain_btnAddTab").Click

更多推荐

“点击"使用VBA的javascript按钮

本文发布于:2023-06-09 04:10:59,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/594965.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:按钮   quot   VBA   javascript

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!