我环顾四周,我不确定此问题是否曾被提出过。我想我已经开始解决方案,但这是我的问题。我在网页上有一个HTML表,里面有一个输入元素,我需要通过VBA访问它。以下是HTML的相关摘要:
<td class="tbl1"><input size="11" type="text" maxlength="9" name="txtCusipNo" value=''><a href="javascript:;" onclick="window.open('/SecFinderII1/SIM_SeekSearch.jsp?clientobjectreference=frmSearchEntry.txtCusipNo&formname=frmSearchEntry&textboxname=txtCusipNo','SecurityFinder','resizable=yes,scrollbars=yes,status=no');"><img src="/Settlement/static/images/pbs/lookup.gif" border="0" alt="Open Security Finder" align="absmiddle"></a> <img name="imgCusipNo" src="/Settlement/static/images/pbs/req.gif" border="0" align="top"></td>
我可以使用以下代码轻松找到此单元格:
Set Cells = HTMLDoc.getElementsByTagName("td")
For Each Cell In Cells
If Cell.className = "tbl1" And Cell.something = something Then
'This is the cell
End If
Next Cell
页面上只有5个单元格,所以没什么大不了的。我还需要做的是弄清楚如何使用input元素。我想通过得到孩子或什么?似乎无法找到任何线索...
答案 0 :(得分:1)
尝试InvokeMember:
Set Cells = HTMLDoc.getElementsByTagName("td")
For Each Cell In Cells
If Cell.className = "tbl1" And Cell.something = something Then
Cell.InvokeMember("click")
End If
Next Cell