我正在尝试从不同的网站收集数据。因此我使用 Excel VBA 并启动 Internet Explorer。我能够填写正常的表格。但有时我必须填写一个带有 jquery 脚本的动态表单。
如果填写了前 2 个字段并触发了事件,则该表单将仅启用所有输入字段(下拉菜单)。
所以我的脚本能够填写表格,但不能触发所需的“重新计算”事件。
如果您用鼠标手动填写表格,它就可以了。我怎样才能模拟这个事件?
这是我的 Excel VBA 脚本:
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
感谢您的帮助
现在我有了解决方案:
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"
谢谢大家。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)