【发布时间】:2019-05-29 16:31:29
【问题描述】:
我是 Excel 宏的新手,我正在尝试自动填充文本框并从下拉列表中选择选项,然后单击提交。
使用宏导航到一个页面,从该页面,我需要在文本框中输入文本,并根据建议,我需要选择选项。
选择该选项后,我需要点击继续使用宏。
这是当前代码(我尝试使用注释行但它不起作用)。
Sub Create_Change()
Dim i As Long
Dim URL As String
Dim IE As Object
Dim objElement As Object
Dim objCollection As Object
Dim HWNDSrc As Long
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
URL = "URL to Navigate"
IE.Navigate URL
Application.StatusBar = URL & " is loading. Please wait..."
Do While IE.ReadyState = 4: DoEvents: Loop
Do Until IE.ReadyState = 4: DoEvents: Loop
Application.StatusBar = URL & " Loaded"
' IE.Document.All("Search for a template").Value = "text to search"
Set IE = Nothing
Set objElement = Nothing
Set objCollection = Nothing
End Sub
HTML 代码:
<input title="Search for a template"
class="change-template__search-input ng-pristine ng-untouched ng-valid"
role="combobox"
aria-expanded="false"
aria-owns="typeahead-258-8737"
aria-autocomplete="list"
type="text"
placeholder="Search for a template"
ng-enter="getRecommendedTemplates(template.search)"
ng-model="template.search"
typeahead="template as template for template in getTemplateList($viewValue)"
typeahead-focus-first="false"
typeahead-on-select="getRecommendedTemplates($item)"
typeahead-min-length="3">
【问题讨论】:
-
有可以测试的网址吗?