Fire event with vba & InternetExplorer.Application to recalculate jquery form

user2929630 picture user2929630 · Oct 30, 2013 · Viewed 13.6k times · Source

I'm trying to gather data from different websites. Therefore i'm using excel vba and start an internet explorer. I'm able to fill out a normal form. But sometimes i have to fill out a dynamic form with a jquery script behind.

The form will only enable all input fields (drop down menus), if the first 2 fields are filled out and an event is fired.

So my script is able to fill out the form but not to fire the "recalculation" event which is needed.

If you fill out the form manually with your mouse it works. How can i simulate this event?

This is my excel vba script:

Sub test_fill_form()

Dim url1 As String
Dim url2 As String
Dim url3 As String

url1 = "https://auto."
url2 = "ar"
url3 = "do.ch/selling/?step=1&uniqueid=8a7d2327-f426-4df7-8291-d6b55fc62e3c"

Dim ie As Object
Set ie = CreateObject("InternetExplorer.Application")

ie.Visible = True
apiShowWindow ie.hwnd, SW_MAXIMIZE
ie.navigate url1 & "ric" & url2 & url3

While ie.readyState <> 4: DoEvents: Wend

ie.document.all("Article_ArticleDetails_AutoRegistrationMonth").Click
ie.document.getElementById("Article_ArticleDetails_AutoRegistrationMonth").value = "1"
ie.document.getElementById("Article_ArticleDetails_AutoRegistrationYear").value = "2013"
End Sub

Answer

user2929630 picture user2929630 · Oct 31, 2013

Thanks for your Help

Now i have the solution:

ie.Document.getElementById("Article__").Click
ie.Document.getElementById("Article_ArticleDetails_").Focus
ie.Document.getElementById("Article_ArticleDetails_").Value = "9"

'This will run the java script / fire the recalc event
ie.Document.parentWindow.execScript "registrationUpdate()", "JavaScript"

Thanks all.