VBA-IE:单击仅包含href属性的HTML元素

时间:2018-01-03 18:38:58

标签: excel-vba ie-automation vba excel

我需要点击“Anmelden”进入下一页。 enter image description here

这些元素在html代码中描述为:

<nav id="main-menu" role="navigation">

          <a href="https://csp.stocko-contact.com/portal/">Startseite</a>
          <a href="https://csp.stocko-contact.com/portal/authenticate.php">Anmelden</a>  </nav>

在我的VBA代码中,我尝试使用代码选择此链接:

Option Explicit
Dim IE As InternetExplorer
Dim l As Object
Dim link As HTMLAnchorElement

(...)

For Each l In IE.Document.getElementsByTagName("a")
    If l.href = "https://csp.stocko-contact.com/portal/authenticate.php" Then
    l.Click
    End If
Exit For
Next

我使用IE8。有什么建议? 提前谢谢。

0 个答案:

没有答案
相关问题