1

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.

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

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

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
1
  • I am trying to understand your question ... is it that you DO want the "Data Saved Successfully" alert message to show, but automatically close itself after a moment or two (thus no need for an OK button)? Or you are asking to not have the "Data Saved Successfully" alert message show at all? Because if it is the latter (no message at all) then just remove the 'alert("Data Saved Successfully")' line right in the code. Commented Mar 25, 2015 at 12:01

2 Answers 2

1

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

eg.

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

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

Comments

-2

I had this problem and the only way I could solve it was by writing a vb script that identifies the pop up and closes it...

After that, you just need to call it from your vba code.

Comments

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.