【问题标题】:VBA "If...Then" for keyword found in HTMLtag Innertext在 HTMLtag Innertext 中找到关键字的 VBA“If...Then”
【发布时间】:2014-01-18 19:52:10
【问题描述】:

是否可以编写一个 If...Then 命令来引用 HTML 内部文本的一部分中的关键字/短语。

例如,我希望运行一个“If...Then”命令,该命令将找到一个带有部分内部文本的标签,包括短语“Records Found.”。如果标签存在,则只有一个标签会在其内部文本中包含此短语。如果此标签存在,我希望工作表中的单元格显示“找到多个记录”

    Dim ErrLi As Object
    Dim ErrObj As Object
    Dim x As Integer

    Set ErrLi = IE.Document.GetElementById("DivCenterTopArea").GetElementsByTagName("li")

    If Not ErrLi Is Nothing Then
      For x = 1 To ErrLi.Length - 1
        If ErrObj.innertext = & "records found." Then
          Range("Q" & (ActiveCell.Row)) = "Multiple Records Found"
        End If
      Next
    End If

【问题讨论】:

    标签: html vba excel innertext


    【解决方案1】:

    使用instr函数

    If instr(1, ErrObj.innertext, "records found.") > 0 Then
          Range("Q" & (ActiveCell.Row)) = "Multiple Records Found"
    End If
    

    【讨论】:

    • 这是票,谢谢!
    猜你喜欢
    • 1970-01-01
    • 2018-03-24
    • 1970-01-01
    • 1970-01-01
    • 2011-03-04
    • 1970-01-01
    • 1970-01-01
    • 2019-11-29
    • 1970-01-01
    相关资源
    最近更新 更多