mercredi 31 mai 2017

Acces a href link with excel and VBA

I want to click a href link that is dynamic, but what i know it is it's position. So i want to click either the first link presented or the third or another depending if it meets the given criteria.I have really very little clue as to what am i doing, as i have little knowledge of programing(still doing VBA tutorials). A point in the right direction would be great.

This is where i am stuck:

Sub useClassnames()
Dim lists As IHTMLElementCollection
Dim anchorElements As IHTMLElementCollection
Dim ulElement As HTMLUListElement
Dim liElement As HTMLLIElement
Dim row As Long
Dim link As IHTMLElement
Dim ie As InternetExplorer

Set ie = New InternetExplorer

With ie
    .navigate "http://ift.tt/2rM7ZqB"
    .Visible = True

    Do While ie.readyState <> READYSTATE_COMPLETE
        DoEvents
    Loop
End With
    Do Until ie.document.getElementsByClassName("KambiBC-event-item__participants-container").Length > 0
        DoEvents
    Loop
row = 1
If Cells(row, 1).Value = 0 And Cells(row, 2).Value = 0 And Cells(row, 3) > 38 Then
Set link = ie.document.getElementsByTagName("a")
For Each l In link
    If link.className = "KambiBC-event-item__link KambiBC-js-event-item-link" Then
        link.Click
        Exit For
    End If
Next l

row = row + 1 End If End Sub




Aucun commentaire:

Enregistrer un commentaire