我对 VBA 并不陌生,但我对任何与 Web 交互的东西都不熟悉。我可以打开有几个图标的网页。我需要有关单击特定图标的帮助。这是我右键单击所需图标并单击“检查元素”时出现的 HTML:
<div title="" class="myapps-myapp resource" position="N" index="22">
<div class="myapps-icon-background"></div>
<a class="myapps-icon" href="#">
<img class="iconImage" alt="SomeName"
src="Resources/Icon/aklhdjQ2QWJGVVQxcHpUcEJ5RG5FcEZwcytzPQ--
?size=48"
iconid="akltdjStWJGVVRxcHpUcEJ7QG3FcEZwtytzMT">
</a>
<div class="myapps-status"></div>
<div class="myapps-name">SomeName</div>
</div>
这是我到目前为止的 VBA 代码:
Sub test()
Dim oHTML_Element As IHTMLElement
Dim oBrowser As Internet Explorer
Dim objIE As Variant
Set objIE = Create Object("InternetExplorer.Application")
objIE.navigate "http://The webpage goes here" 'This open the site
While objIE.readyState <> READYSTATE_COMPLETE And objIE.readyState & _
<> READYSTATE_LOADED
DoEvents
Wend
For Each oHTML_Element In objIE.document.getElementsByName & _
("SomeName")
oHTML_Element.Click 'This does not work!
Next
End Sub
任何帮助将不胜感激。谢谢!