VBA填写Internet Explorer表格Excel

问题描述 投票:0回答:1

我对此是完全陌生的,已经花了几天时间来完成这项工作,但惨败。

简单来说,我只想将信息填写到图片左侧的站点“选择选择器”部分中

有一个元素名称'picker',但它根本不起作用(再次,我对此并不陌生)。

[搜索栏正在使用jQuery自动完成功能完成,该功能会提交已选择从自动完成功能框导航到关联者的表单

我尝试过这些,但是没有运气

IE.Document.All("picker").Value = "Testing"

IE.Document.GetElementByID("pickerCtrl.currentPicker").Value = "Testing"

IE.Document.GetElementsByClassName("input-group input-group-sm").Item(0).Value = "Testing"

有人可以帮我解决这个问题吗?

PS。是否可以仅将行复制并粘贴到光标所在的当前位置?

我的意思是,我可以发送sendkeys选项卡18次以转到该特定的搜索栏,但不知道如何从excel工作表中插入整行...

例如,IE.Document.all(“ picker”)。Value = ThisWorkbook.Sheets(“ Main_1”)。Range(“ B”&intRow).Value

SITEInspect Element

vba internet-explorer autofill
1个回答
0
投票

尝试使用下面的示例进行测试可能有助于解决问题。

Sub demo1()

    Dim i As Long
    Dim URL As String
    Dim IE As Object
    Dim HWNDSrc As Long

    Set IE = CreateObject("InternetExplorer.Application")

    IE.Visible = True

    URL = "D:\Backup20190913\tests\367.html"

    IE.Navigate URL

    Do While IE.ReadyState = 4: DoEvents: Loop
    Do Until IE.ReadyState = 4: DoEvents: Loop

    IE.Document.querySelector("[name='picker']").Value = "test value"

    Stop
    Set IE = Nothing

End Sub

HTML

<input class="form-control ng-valid ng-isolate-scope ng-touched ng-dirty" ng-model="pickerCtrl.currentpicker" name="picker" type="text" typeahead="" typeahead-source="pickerCtrl.getpickerStrings()" ng-disabled="pickerCtrl.errorLoadingPickers || pickerCtrl.noPickerstrings" ng-hide="pickerCtrl.disableTypeahead" autocomplete="off">

输出:

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.