Reputation: 143
I want to Click on a link using VBA. The link is on a page and doesn't have a tag or id. The link only has a "link text". The link looks like this:
<a href="http://bulksell.ebay.de/ws/eBayISAPI.dll?FileExchangeDownload&RefId=40637977">Herunterladen</a>
I made the following code in VBA, but I think that it doesn't work because the link doesn't have an ID or something.
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
Upvotes: 0
Views: 6016
Reputation: 8104
Try using innerText
instead of classname
. Also, you should refer to your control variable l
, not Link
.
For Each l In Link
If l.innerText = "Herunterladen" Then
l.Click
Exit For
End If
Next l
Hope this helps!
Upvotes: 2