vba在网页中跳过弹出消息框 [英] vba skip popup message box in webpage

查看:796
本文介绍了vba在网页中跳过弹出消息框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是初学者,拼命寻求帮助。我会请求您的支持,并提前道歉,因为不好的措辞和最终缺乏信息(再次,我是菜鸟)。我正在构建一个Excel宏来填写(私人)网页,填写所需数据后,我也可以调用提交数据/表单的javascript函数。但是,它似乎是一个从网页的消息,我无法确认(总是确定/输入)或简单的跳过。宏只停止,我无法在ok按钮中手动点击任何操作。我花了几个小时搜索和尝试不同的解决方案,但似乎没有任何效果,可能是由于我的技能不好。以下我发送的代码是打败我的(希望就够了)。期待您的帮助



我的代码

  DIM HTMLdoc作为MSHTML .HTMLDocument 

'提交数据但卡在弹出消息框
HTMLdoc.all.Item
调用HTMLdoc.parentWindow.execScript(licitarLeilao();,JScript )

WEBPAGE

  ... 
函数licitarLeilao(){
var ultimaLicitacao = document.getElementById('ultimaLicitacao')。
var valorLicitar = document.getElementById('valorLicitar')。

if(ultimaLicitacao ==' - '){
ultimaLicitacao = document.getElementById('valorBase')。
}

var racio = toNum(valorLicitar)/ toNum(ultimaLicitacao);

if(racio< 1.5){
if(!confirm('Confirma o valor delicitação('+ valorLicitar +'eur。)doleilão?')){
返回false;
}
}
else {
if(!confirm('ATENÇÃO!! O valor delicitaçãoémuito superioràúltimalicitação。\\\
\\\
Confirma o valor de licitação('+ valorLicitar +'eur。)doleilão?')){
return false;
}
}

var flow = document.getElementById('flow');
flow.value ='8';

document.formulario.submit();
}


解决方案

您可以尝试覆写 window.confirm 具有不同的功能:

 使用HTMLdoc.parentWindow 
.execScriptwindow.confirm = function(){return true;};,JScript
.execScriptlicitarLeilao();,JScript
End with

在为我工作的测试页面中。



注意:如果网页上有其他代码使用确认,那么该代码的功能可能会受到影响。


I’m a beginner and desperately seeking for help. I would kindly request your support and apologize in advance for the poor wording and eventual lack of info (again, I’m a rookie). I’m building an Excel macro to fill in a (private) webpage and after filling in the requested data, I’m also able to call the javascript function that submits the data/form. However, it appears a "Message from webpage" that I’m unable to confirm (always "ok"/enter) or simple skip. The Macro just stops and I can’t do anything without clicking manually in the "ok" button. I’ve spend several hours searching and trying different solutions but nothing seems to work, probably due to my poor skills. Hereunder I send the code that is beating me hard (hope is enough). Looking forward for your help

MY CODE

DIM HTMLdoc As MSHTML.HTMLDocument

' Submits data but gets stuck in the popup message box
HTMLdoc.all.Item
Call HTMLdoc.parentWindow.execScript("licitarLeilao();", "JScript")

WEBPAGE

...
function licitarLeilao(){
    var ultimaLicitacao = document.getElementById('ultimaLicitacao').value;
    var valorLicitar = document.getElementById('valorLicitar').value;

    if(ultimaLicitacao == ' -- '){
        ultimaLicitacao = document.getElementById('valorBase').value;
    }

    var racio = toNum(valorLicitar) / toNum(ultimaLicitacao);

    if (racio < 1.5) {
        if(!confirm('Confirma o valor de licitação (' + valorLicitar +' eur.) do leilão?')){
            return false;
        }   
    }
    else {  
        if(!confirm('ATENÇÃO!! O valor de licitação é muito superior à última licitação. \n\n Confirma o valor de licitação (' + valorLicitar +' eur.) do leilão?')){
            return false;
        }
    }   

    var flow = document.getElementById('flow');
    flow.value = '8';

    document.formulario.submit();
}

解决方案

You can try overwriting window.confirm with a different functionality:

With HTMLdoc.parentWindow
    .execScript "window.confirm = function(){return true;};", "JScript"
    .execScript "licitarLeilao();", "JScript"
End With

In a test page that worked OK for me.

NOTE: if there's any other code on the web page which uses confirm then the functionality of that code may be impacted.

这篇关于vba在网页中跳过弹出消息框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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