我是Excel VBA的新手。我目前正在做IE Excel自动化,我想点击网页上的标签。
HTML源代码是:
<td class = t19TabItem><a href="javascript:apex.submit('D_Price');">Compliance</a></td>
点击标签合规性的任何帮助。
我使用下面的代码,通过使用内部html找到了标签合规性,但它没有单击“合规性”选项卡。它抛出错误,因为对象不具有此属性。
set link=IE.document.getElementsByTagName("a")
if link.InnerHTML="compliance" and link.href="javascript:apex.submit('D_Price')" then
click link
end if
如何点击合规标签?
答案 0 :(得分:0)
尝试使用以下参考的代码
Microsoft HTML对象库
Microsoft Internet Controls **
Sub test()
Dim oHTML_Element As IHTMLElement
Dim oBrowser As InternetExplorer
Dim ie As Variant
Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = True
ie.navigate "your web link" 'Your weblink goes here
While ie.readyState <> READYSTATE_COMPLETE And ie.readyState <> READYSTATE_LOADED
DoEvents
Wend
Application.Wait (Now() + TimeValue("00:00:03"))
For Each oHTML_Element In ie.document.getElementsByTagName("a")
If oHTML_Element.innerHTML = "compliance" Then
oHTML_Element.Click
End If
Next
End Sub