vba get 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
Set elems = ht.getElementsByClassName("title may-blank")
For Each elem In elems
Debug.Print (elem.innerText)
Next
Set button = ht.querySelector("[rel='nofollow next']")
button.Click
Next i
End Sub