admin管理员组文章数量:1327308
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
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
Share
Improve this question
asked Oct 30, 2013 at 18:05
user2929630user2929630
511 gold badge1 silver badge6 bronze badges
1
- Thank you for your reply. the problem is, that when i fill the Dropdown Marke with a value: ie.document.getElementById("Article_ArticleDetails_AutoMakeId").value = "9" (BMW) there should be data loaded in the subsequent dropdown (Modell): ie.document.getElementById("Article_ArticleDetails_AutoModelId") if you do that with your mouse, data is loaded in the dropdown: AutoModelId (Modell). Is it possible to fire an event, that this data is loaded in that dropdown? thanks a lot! – user2929630 Commented Oct 31, 2013 at 12:04
2 Answers
Reset to default 3Thanks 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.
For the link provided the form has disabled dropdown but it has the options element in it so you may set disabled as false and can do further processing. (The dropdown are not waiting for ajax request to get filled)
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"
ie.document.getElementById("Article_ArticleDetails_AutoMakeId").disabled = False
ie.document.getElementById("Article_ArticleDetails_AutoModelId").disabled = False
ie.document.getElementById("Article_ArticleDetails_AutoFuel").disabled = False
End Sub
版权声明:本文标题:javascript - Fire event with vba & InternetExplorer.Application to recalculate jquery form - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742204358a2432536.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论