vba get html element code example
Example: vba get html element
Sub website_test()
Dim ie As Object
Dim ht As HTMLDocument
Dim button As Object
Dim i As Integer
For i = 0 To 5
Set ie = CreateObject("InternetExplorer.Application")
With ie
.Visible = True
.navigate ("https://old.reddit.com/r/fashion/new/")
Do Until .readyState = 4
DoEvents
Loop
Set ht = .document
End With
' List of elemenents by class name
Set elems = ht.getElementsByClassName("title may-blank")
For Each elem In elems
Debug.Print (elem.innerText)
Next
' Element by rel value
Set button = ht.querySelector("[rel='nofollow next']")
button.Click
Next i
End Sub