Trying to work on a Macro to login into a website and then download some data. Currently I am having trouble getting it to click on a link in the site.
Code:
Sub GetHTLMDocuments()
    Dim IE As New SHDocVw.InternetExplorerMedium
    Dim HTMLDoc As MSHTML.HTMLDocument
    Dim HTMLInput As MSHTML.IHTMLElement
    Dim HTMLButtons As MSHTML.IHTMLElementCollection
    Dim HTMLButton As MSHTML.IHTMLElement
    IE.Visible = True
    IE.navigate "xxx.yyy"
    Do While IE.readyState <> READYSTATE_COMPLETE
        Application.Wait Now + TimeValue("00:00:03")
        DoEvents
    Loop
    
    Application.Wait Now + TimeValue("00:00:02")
    
    ShowWindow IE.hwnd, SW_MAXIMIZE
    Set HTMLDoc = IE.document
    
    Application.Wait Now + TimeValue("00:00:02")
    
    Set ElementCol = IE.document.getElementById("periods")
      For Each btnInput In ElementCol
          If btnInput.Value = "selected" Then
              btnInput.Click
              Exit For
          End If
      Next btnInput
    IE.Quit
End Sub
Here's the html code from the site:
I would like to change the class which state the selected (or unselected) of the "option" element, any idea?
also tried to print all the Elements by class name......
Debug.Print InStr(1, HTMLDoc.body.outerHTML, "periods", vbTextCompare)
Dim dd As Variant
dd = IE.document.getElementsByClassName("periods")(0).innerText
IE.document.querySelector("[title='periods']").Click
    For Each link In IE.document.getElementsByTagName("*")
        With link
            If .innerText = "periods" Then
            link.Click
            End If
        End With
    Next
