如果只知道ng-model,则用VBA填充IE表单

时间:2017-09-19 21:15:40

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

网页:

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

所有字段的类型和类都相同。所以我只能使用Ng模型。如何填写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

1 个答案:

答案 0 :(得分:0)

您尝试使用

吗?
Set oIE = New InternetExplorerMedium