0

我环顾四周,我不确定以前是否有人问过这个问题。我想我已经开始解决问题了,但这是我的问题。我在网页上有一个 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>&nbsp;<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 个单元格,所以没什么大不了的。我仍然需要做的是弄清楚如何使用输入元素。我猜是通过得到孩子还是什么?似乎找不到任何线索...

4

1 回答 1

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
于 2013-11-07T23:01:39.373 回答