【问题标题】:Fill IE form with VBA if only ng-model is known如果只知道 ng-model,则使用 VBA 填充 IE 表单
【发布时间】:2017-09-19 21:15:39
【问题描述】:

网页:

input ng-model="vm.form.model.maxDepth" type="text" 
class="form-control ng-pristine ng-valid ng-not-empty ng-touched" style=""

类型和类在所有字段中都相同。所以我只能使用 Ng-model。 IE表单如何填写?

这些都不起作用:

Set oIE = CreateObject("InternetExplorer.Application")
oIE.Navigate ("https://page.com")
Set daug = Worksheets("Sheet1").Range("G2")
i = 1
oIE.document.all.Item("vm.form.model.maxDepth")(1).Focus
oIE.document.all("vm.form.model.maxDepth")(1).innerText = daug(i)
oIE.document.all("vm.form.model.maxDepth")(1).Value = daug(i)
oIE.document.all("vm.form.model.maxDepth")(1).innerText = daug(i)
oIE.document.parentWindow.execScript.angular.element(document.getElementByTagName("input")(15)).scope().vm.form.Model.maxDepth = "112233"
oIE.document.qetElementsByClassName("vm.form.model.maxDepth").Value = daug(i)
oIE.document.parentWindow.execScript.angular.element(document.getElementByTagName("input")(15)).scope().vm.form.Model.maxDepth = "112233"

For Each element In oIE.document.getElementsByTagName("input")
If InStr(element.vbTextCompare, "vm.form.model.maxDepth") <> 0 Then

If element.hasAttribute("ng-model") & element.getAttribute("ng-model") = "vm.form.model.maxDepth" Then
Debug.Print (element.innerText)
    element.Value = daug(i)
    Exit For
End If
Next

【问题讨论】:

  • 我正在解决同样的问题here 如果您可以分享您尝试更改的下拉框的更完整的 html,如果我们中的任何一个解决了问题,我们可以分享更通用的解决方案.

标签: angularjs excel vba internet-explorer angular-ngmodel


【解决方案1】:

你尝试过使用

Set oIE = New InternetExplorerMedium

【讨论】:

  • 如果对某个问题有疑问,请参阅部分
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多