WebBrowser Control automation problem.

Discussion in 'Programming' started by Tim_Myth, Jul 11, 2008.

  1. #1
    I have a webbrowser control embeded in an Excel workbook. I use it to copy data from the spreadsheet and enter it into form fields on a web page that updates an employee database. My proceedure clicks the New button, sets the values of the form fields, clicks the Submit button, and loops through all the cells in my sheet until it has added all the data.

    My problem is that when I click the submit button, I need to wait for a second or two for the web page to update or else I get a javascript pop up that asks if I'm sure I want to abandon the changes when the New button is clicked again. The web interface for the database uses ajax, so the documentcomplete event does not fire. The statuschange event fires constantly, and setting the webbrowser control to silent only stops javascript error dialogs, not javascript alerts.

    I have tried adding application.wait to my code, but that causes the embedded browser control to wait too, which simply results in there being a two second delay before the web page pops up the damned "Are you sure you want abandon these changes?" alert. How can I cause Excel to wait for 2 seconds without causing the webbrowser control to also wait. Or, is there any event I can watch for that would tell me when the ajax portion is finished?
    
    Private Sub Action_Button_Click()
        'Several lines of code removed
        obj.getElementById("dojo_TurboButton_14").Click 'The Submit button
        Sheet2.Rows(2).Delete
        Application.Wait (Now + TimeValue("0:00:02"))
        If Sheet2.Range("a2").Text <> "" Then
            Call Action_Button_Click
        Else
            Exit Sub
        End If
    End Sub
    
    Code (vb):

     
    Tim_Myth, Jul 11, 2008 IP