1

Im having a problem dealing with the java scripts alerts..

I am able to navigate and enter data in the webpage but when selecting different item to update a modal alerts displayed..

How can I click the OK button tru VBA?

Any help please...

Here is the code in the webpage i think firing when i select an item triggering the alert..

This is what i see in the HTML scripts:

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;
}
}
}

This is my code:

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 Answer 1

1

One immediate solution would be to use the SendKeys function.

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

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

You can find more information on SendKeys here.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks.. It works ... I just have a few clarifications... Where does the "n" came from the source? What is the use of it? Though, I know that using sendkeys is not reliable... do we have other options to consider?
I used "n" in case the dialog was a "Yes"/"No" prompt, hence sending it an "n" would select "No". I have found SendKeys to work most of the time. Your other option might be to create a Web client in VBA by automating Internet Explorer or by using WinInet. Your client could do the task you are performing manually.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.