Excel 使用Internet Explorer中的vba从组合框中选择项目
以下值表示网站上的组合框/组合列表。我正在尝试使用VBA从下拉列表中选择项目3。我试过好几种方法,但我没有幸运地选择了上述项目。我试着在Google和Stack上寻找解决方案,但没有找到任何有效的方法Excel 使用Internet Explorer中的vba从组合框中选择项目,excel,vba,internet-explorer,Excel,Vba,Internet Explorer,以下值表示网站上的组合框/组合列表。我正在尝试使用VBA从下拉列表中选择项目3。我试过好几种方法,但我没有幸运地选择了上述项目。我试着在Google和Stack上寻找解决方案,但没有找到任何有效的方法 <DIV id=ext-gen256 class="x-layer x-combo-list x-combo-list-small" style="FONT-SIZE: 10px; HEIGHT: 92px; WIDTH: 113px; POSITION: absolute; LEFT: 7
<DIV id=ext-gen256 class="x-layer x-combo-list x-combo-list-small" style="FONT-SIZE: 10px; HEIGHT: 92px; WIDTH: 113px; POSITION: absolute; LEFT: 744px; Z-INDEX: 12007; TOP: 235px; VISIBILITY: visible">
<DIV id=ext-gen257 class=x-combo-list-inner style="HEIGHT: 90px; WIDTH: 111px">
<DIV class="x-combo-list-item" _nodup="30829" viewIndex="0">Select</DIV>
<DIV class="x-combo-list-item" _nodup="30829" viewIndex="1">Item 1</DIV>
<DIV class="x-combo-list-item" _nodup="30829" viewIndex="2">Item 2</DIV>
<DIV class=""x-combo-list-item" _nodup="30829" viewIndex="3">Item 3</DIV>
<DIV class="x-combo-list-item" _nodup="30829" viewIndex="4">Item 4</DIV></DIV></DIV>
这似乎不起作用。非常感谢您的帮助。谢谢 我认为您必须将x-combo-selected添加到类名中,因为它在HTML中是这样显示的。我认为您必须将x-combo-selected添加到类名中,因为它在HTML中是这样显示的
Dim inputE As MSHTML.HTMLHtmlElement
Set inputE = IE.document.getElementsByClassName("x-combo-list-item")
If inputE.innerText = "Item 3" Then
inputE.Select
End If