我想使用 excel VBA 通过 getElementByID 函数选择下拉列表。但是,我在以下行遇到错误 91:ID.Focus。我想这意味着 VBA 没有找到 item:select1,但我不知道为什么。谁能帮我弄清楚我错过了什么?
这是我的代码
sub Search()
Dim IE as InternetExplorer
Set IE = New InternetExplorer
IE.visible = True
IE.navigate " myURL "
Do while IE.Busy = True Or IE.ReadyState<>4: DoEvents:Loop
Dim ieDoc As MSHTML.HTMLDocument
Set ieDoc = IE.Document
Dim ID As Object
Application.Wait Now + TimeValue("00:00:01")
Set ID = ieDoc.getElementsByTagName("frame")(0).Document.getElementByID("selectgroup1")
ID.Focus
ID.selectedIndex =3
ID.FireEvent ("onchange")
End sub
下面是HTML
<HTML>
<head>...<head>
<frameset id="Frame" cols="36,1,*" border="0" frameBorder="0" frameSpacing="0">
<frame name="frame1" src="/...jsp?caseId=111111&group=0" frameBorder="0" scrolling="auto">
<html>
<head>...<head>
<body uid="5" onload="initial()" onresize="null" onbeforeprint="null" onafterprint="null">
<table>
<tbody>
<tr class="class1">...<tr>
<tr class="class2">...<tr>
<tr class="class3">
<th onclick="jump(-1)" rowSpan="1" colSpan="1"><</th>
<td width="100%" roSpan="1" colSpan="1">
<select id="selectgroup1" onchange="reload">...</select>
<td>