使用VBA代码禁用网页的警报消息 [英] Disable Alert message of a webpage using VBA code

查看:81
本文介绍了使用VBA代码禁用网页的警报消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用VBA代码打开一个网页,其中包含用户将在其中填写数据的表格.我有包含数据的Excel文件.我编写了VBA代码,该代码从excel读取数据并将其放在网页上.在网页上填写信息后,我单击保存"按钮.我已经使用VBA代码完成了所有这些工作,以便可以自动完成.我有500个用户数据,因此我运行了500次循环.所有这一切都罚款.

I am opening a webpage using VBA code which contains form where data will be filled by user. I have excel file which contains data. I write VBA code that read the data from excel and put it on webpage. After filling information on webpage I click on Save button. All this work I had done using VBA code so that it can be done automatically. I have 500 users data hence I run the loop 500 times. All it done fines.

只有一个问题出现,那就是当我单击保存"按钮以网页形式填写数据后,弹出消息是您的数据已成功保存".它具有确定"按钮.现在,我的程序在这里停止,需要用户干预才能手动单击确定"按钮.

Only one problem come and it is that after filling data in webpage form when I click on save button a popup message comes "Your data saved successfully". It has "OK" button. Now my program stops here and need user intervention to manually click on "OK" button.

是否可以使用VBA代码停止此弹出消息框,从而不再需要手动干预?

Is there any way using VBA code by which we can stop this popup message box, so that manual intervention is no longer required?

我也阅读了该网页和为该网页编写的Javascript.我发现单击保存"按钮时,会调用一个名为 savedetails()的函数.在此函数内部,有一个 alert()函数.示例代码在这里

I read the webpage and Javascript written for webpage also. I found that when Save button is clicked a function called savedetails() . Inside this function a alert() function is there. Sample code here

function saveDetails()
{
/* get details of member*/
---
---
---
---
---
if (xml.status == 200 || window.location.href.indexOf("http") == -1) {  
    var successCode = "";
alert("Data Saved Successfully");
var tes = xml.responseText;

/*  if (successCode == '1') {  */

document.webDataForm.submit();
remove_popup();
};
}

每个htmlColl中的htmlInput的VBA代码

VBA Code For Each htmlInput In htmlColl

  If Trim(htmlInput.ID) = "btn" Then
    If Trim(htmlInput.Name) = "btnfinal" Then
                              htmlInput.Click  'After this "Data Saved Successfully popup message comes and program need user intervention
                             temp = htmlInput.getAttribute("onClick")
                             MsgBox temp
                            'IE.document.getElementById("clearRelItems").removeAttribute ("o n C l i c k")
                    'Call iedoc.parentWindow.execScript("window.confirm = function saveBankDetails() {return true}", "JavaScript")  // Not worked
                             'htmlInput.removeAttribute ("onClick") //Not worked
                             'htmlInput.setAttribute "onClick", "return TRUE"   //Not worked
                            'Application.SendKeys "{ENTER}", True // Not worked
                            Exit For
                        End If
                    End If
            Next htmlInput

推荐答案

您可以尝试使用Application.DisplayAlerts函数将行换行,该函数会生成不需要的显示框;

You could try wrapping the line with the Application.DisplayAlerts function that produces the display box you don't want;

例如

If Trim(htmlInput.ID) = "btn" Then
    If Trim(htmlInput.Name) = "btnfinal" Then
          Application.DisplayAlerts = False
              htmlInput.Click 
          Application.DisplayAlerts = True

.... Further Code

这篇关于使用VBA代码禁用网页的警报消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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