Want to click the hyperlink ( tag) 'abc' in IE through Excel VBA. Tried getElementbyTag/getElementsbyName/getElementsbyClassName but no luck so please help me on this
<a href = 'xyz'> abc </a>
Dim objIE As InternetExplorer
set objIE = New InternetExplorer
objIE.Visible = True
objIE.Document.getElementsByTagName("xyz").Click
答案 0 :(得分:2)
getElementsByTagName
会返回一组链接,因此您需要循环查找所需的链接。
Dim l
For Each l in objIE.Document.getElementsByTagName("a")
If l.innerText = "abc" Then
l.Click
Exit For
End If
Next l