【发布时间】:2020-11-21 04:36:38
【问题描述】:
我一直在尝试使用 Excel VBA 在 IE11 中选择 2 个单选按钮中的 1 个。 这是 HTML:
<BODY><TABLE cellSpacing=0 cellPadding=0 width="90%" align=center border=0>
<TBODY>
<TR>
<TD>
<TABLE height=18 cellSpacing=0 cellPadding=0 width="100%" align=center bgColor=#336699 border=0>
<FORM method=post name=ChangeAirportForm action=/mas/ChangeAirportAction.do>
<TBODY>
<TR class=trH align=center>
<TD vAlign=top width="1%"><IMG border=0 src="https://mas.bafs.co.th/mas/include/images/l.gif" width=8 height=18></TD>
<TD width="10%"> </TD>
<TD width="29%">Airport Site Code</TD>
<TD width="29%">Airport Site Name</TD>
<TD width="30%"> </TD>
<TD vAlign=top width="1%" align=right><IMG border=0 src="https://mas.bafs.co.th/mas/include/images/r.gif" width=8 height=18></TD></TR>
<TR class=trA align=center>
<TD> </TD>
<TD><INPUT style="BORDER-TOP: 0px; BORDER-RIGHT: 0px; BORDER-BOTTOM: 0px; BORDER-LEFT: 0px" CHECKED type=radio value=1 name=airport></TD>
<TD>DMK</TD>
<TD>Donmueang</TD>
<TD> </TD>
<TD> </TD></TR>
<TR class=trB align=center>
<TD> </TD>
<TD><INPUT style="BORDER-TOP: 0px; BORDER-RIGHT: 0px; BORDER-BOTTOM: 0px; BORDER-LEFT: 0px" type=radio value=4 name=airport></TD>
<TD>BKK</TD>
<TD>Suvarnabhumi</TD>
<TD> </TD>
<TD> </TD></TR></FORM></TBODY></TABLE></TD></TR></TBODY></TABLE></BODY>
</html>
我希望选择的单选按钮是type=radio value=4 name=airport
Sub select_radio_button()
Dim sUrl As String: sUrl = xxxxx
Dim oIE As New SHDocVw.InternetExplorer
oIE.Visible = True
oIE.Navigate sUrl
Dim oIEdoc As Object
Set oIEdoc = oIE.Document
Dim oColl as Object
Set oColl = oIEdoc.getElementsByTagName("input")
Dim obj as Object
For Each obj in oColl
If obj.getAttribute("type") = "radio" And obj.getAttribute("value") = 4 Then obj.Click
Next obj
End Sub
【问题讨论】:
标签: html excel vba internet-explorer