【问题标题】:Accessing an input element embeded in an HTML table through VBA通过 VBA 访问嵌入在 HTML 表格中的输入元素
【发布时间】:2013-11-19 16:16:49
【问题描述】:

我环顾四周,我不确定以前是否有人问过这个问题。我想我已经开始解决问题了,但这是我的问题。我在网页上有一个 HTML 表格,其中内置了一个输入元素,我需要通过 VBA 访问它。这是HTML的相关sn-p:

<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 个单元格,所以没什么大不了的。我仍然需要做的是弄清楚如何使用输入元素。我猜是通过得到孩子还是什么?似乎找不到任何线索...

【问题讨论】:

    标签: html vba dom html-table


    【解决方案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
    

    【讨论】:

      猜你喜欢
      • 2020-10-07
      • 2018-03-08
      • 2020-09-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-06-06
      相关资源
      最近更新 更多