function ConfirmSave()
var Ok = confirm('Are you sure all Documents and Information are attached and correct before saving?');
if(Ok)
return true;
return false;
function submitbutton_click() {
document.getElementById('FileAttachement2_hdnButtonFlag').value = "SAVE";
var submitbutton = document.getElementById('cmdDownSave');
var uploadobj=document.getElementById('FileAttachement2_Uploader1');
if(!window.filesuploaded)
if (!ConfirmSave()) return false;
if(uploadobj.getqueuecount()>0)
uploadobj.startupload();
//var uploadedcount=parseInt(submitbutton.getAttribute("itemcount"))||0;
//if(uploadedcount>0)
return true;
//alert("Please browse files for upload");
return false;
window.filesuploaded=false;
return true;
在手动过程中,当我单击“保存”按钮时,页面将弹出一个确认消息框,当弹出窗口出现时,我的宏将停止运行,除非单击该按钮.
这是我试过的代码,点击保存按钮,
Set ElementNameV = HTMLDoc.getElementsByName("cmdsave")
ElementNameV(0).click
我也尝试使用removeattribute和setattribute,弹出消息消失但它没有上传文件,因为我需要按下确认消息框中的’确定’,单击保存按钮开始文件上传时出现.
ElementNameV(0).removeAttribute ("onclick")
ElementNameV(0).setAttribute "onclick", "return true"
ElementNameV(0).click
我尝试使用下面的脚本运行JavaScript函数,但它也显示确认弹出消息框:
Call HTMLDoc.parentWindow.execScript("submitbutton_click()")
解决方法:
你应该能够用一个只返回true的函数覆盖ConfirmSave函数:
HTMLDoc.parentWindow.execScript "window.ConfirmSave = function(){return true;};"
HTMLDoc.parentWindow.execScript "window.confirm = function(){return true;};"
HTMLDoc.parentWindow.eval "window.confirm = function(){return true;};"
在单击按钮之前运行它.
经过测试并在IE11中运行
标签:javascript,vba,excel-vba,popup,automation
来源: https://codeday.me/bug/20190927/1824616.html
我需要通过IE确认’确定’/’取消’弹出消息.我在VBA脚本中运行JavaScript函数时遇到问题.我的JavaScript:function ConfirmSave(){var Ok = confirm('Are you sure all Documents and Information are attached and correct before saving?');if(Ok)retu...
STEP1查看是否有Java环境# java --version没有Java的话请先安装# yum install java2. 查看java安装路径# ls -lrt /etc/alternatives/java 3. 修改java配置文件# vim /etc/profile
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-11.0.5.10-0.e...
function filter(sheet, rangeStr, col, value) {
sheet.range(rangeStr).AutoFilter(col, value);
//取消过滤
function filterCancel(sheet, rangeStr) {
sheet.range(rangeStr).AutoFilter;
Private Declare Sub mouse_event Lib "user32" _
(ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, _
ByVal cButtons As Long, ByVal dwExtraInfo As Long)
其
中
,`dwFlags` 参数指定鼠标事件的类型,`dx` 和 `dy` 参数指定鼠标的水平和垂直坐标,`cButtons` 参数指定鼠标按钮的状态,`dwExtraInfo` 参数为鼠标事件提供附加信息。