VBA关闭Java警报弹出窗口,名称为“来自网页的消息”

时间:2013-08-06 08:58:22

标签: excel-vba vba excel

我在处理java脚本警报时遇到问题..

我能够在网页中导航和输入数据,但在选择不同的项目时更新显示的模态警报..

如何点击确定按钮tru VBA?

任何帮助请...

当我选择触发警报的项目时,我认为这是网页中的代码。

这就是我在HTML脚本中看到的:

function onUpdatedShowAlertTS(varControl) {


if (varControl == "ddlProjectStatus") {
var varconfirm = document.getElementById('ctl00_Tabs_pnlCaptureTSMetrics_CaptureTSMetrics_hdnReleaseStatusConfirmation');
if (varconfirm.value == "true") {
var varControlId = document.getElementById('ctl00_Tabs_pnlCaptureTSMetrics_CaptureTSMetrics_ddlProjectStatus');
var value = varControlId.options[varControlId.selectedIndex].innerText;
alert('Release status is reset to ' + value + ' successfully and validation status is Pending.');
document.getElementById('ctl00_Tabs_pnlCaptureTSMetrics_CaptureTSMetrics_hdnReleaseStatusConfirmation').value = "false";
}
}


if (varControl == "ddlReleaseName") {
var varconfirm = document.getElementById('ctl00_Tabs_pnlCaptureTSMetrics_CaptureTSMetrics_hdnReleaseNameConfirmation');
if (varconfirm.value == "true") {
alert('Release status and and validation status is reset successfully.');
var isReadOnlyStatus = '0'
if (!(isReadOnlyStatus == 1)) {
document.getElementById('ctl00_Tabs_pnlCaptureTSMetrics_CaptureTSMetrics_hdnReleaseNameConfirmation').value = "false";
document.getElementById('ctl00_Tabs_pnlCaptureTSMetrics_CaptureTSMetrics_btnSaveValidate').disabled = false;
}
}
}

这是我的代码:

ieDoc.getElementById("ctl00_Tabs_pnlCaptureTSMetrics_CaptureTSMetrics_hdnConfirmationforReleaseChange").Click
ieDoc.getElementById("ctl00_Tabs_pnlCaptureTSMetrics_CaptureTSMetrics_hdnConfirmationforReleaseChange").setAttribute "value", "true"
ieDoc.getElementById("ctl00_Tabs_pnlCaptureTSMetrics_CaptureTSMetrics_hdnConfirmationforReleaseChange").setAttribute "type", "hidden"

1 个答案:

答案 0 :(得分:1)

一个直接的解决方案是使用SendKeys函数。

Application.SendKeys "n"          ' Send the latter "n" to the dialog

Application.SendKeys "{ENTER}"    ' Send ENTER to the dialog

您可以在SendKeys here找到更多信息。