我想点击使用VBA的链接。该链接位于页面上,没有标记或ID。该链接只有一个“链接文本”。链接如下所示:
<a href="http://bulksell.ebay.de/ws/eBayISAPI.dll?FileExchangeDownload&RefId=40637977">Herunterladen</a>
我在VBA中制作了以下代码,但我认为它不起作用,因为该链接没有ID或其他内容。
Private Sub IE_orderdata_downloaden()
Dim i As Long
Dim IE As Object
Dim objElement As Object
Dim objCollection As Object
' Create InternetExplorer Object
Set IE = CreateObject("InternetExplorer.Application")
'IE.Visible = False
IE.Navigate "http://k2b-bulk.ebay.de/ws/eBayISAPI.dll?SMDownloadPickup&ssPageName=STRK:ME:LNLK"
' Wait while IE loading...
Do While IE.Busy
Application.Wait DateAdd("s", 1, Now)
Loop
IE.Visible = True
Set Link = IE.document.getElementsByTagName("a")
For Each l In Link
If Link.classname = "Herunterladen" Then
Link.Click
Exit For
End If
Next l
End Sub
答案 0 :(得分:1)
尝试使用innerText
代替classname
。另外,您应该引用控件变量l
,而不是Link
。
For Each l In Link
If l.innerText = "Herunterladen" Then
l.Click
Exit For
End If
Next l
希望这有帮助!