我在其他地方多次使用的此代码无法选择此html元素。
我已经尝试了此代码的多种变体,getelementbyid,bytagname和classname。
Dim DDList As MSHTML.IHTMLElement
Dim DDOps As MSHTML.IHTMLElementCollection
Dim DDOp As MSHTML.IHTMLElement
Dim DDOpID As Integer
Dim SM As MSHTML.IHTMLElement
Set HTMLDoc = ie.document
Set DDList = HTMLDoc.getElementsByClassName_
("reportViewer$ctl04$ctl15$ddValue")(0)
Set DDOps = DDList.getElementsByTagName("option")
DDOpID = 6
Set DDOp = DDOps(DDOpID)
DDOp.Click
这是HTML
<SELECT id=reportViewer_ctl04_ctl15_ddValue class=aspNetDisabled
style="FONT-SIZE: 8pt; FONT-FAMILY: Verdana; WIDTH: 127px"
name=reportViewer$ctl04$ctl15$ddValue>
<OPTION selected value=1>JANUARY </OPTION>
<OPTION value=2>FEBRUARY </OPTION>
<OPTION value=3>MARCH </OPTION>
<OPTION value=4>APRIL </OPTION>
<OPTION value=5>MAY </OPTION>
<OPTION value=6>JUNE </OPTION>
<OPTION value=7>JULY </OPTION>
<OPTION value=8>AUGUST </OPTION>
<OPTION value=9>SEPTEMBER </OPTION>
<OPTION value=10>OCTOBER </OPTION>
<OPTION value=11>NOVEMBER </OPTION>
<OPTION value=12>DECEMBER </OPTION></SELECT>
我希望这段代码会选择网页上的文本框,而是生成
运行时错误'91':对象变量或未设置块变量。