Emanuele
Emanuele

Reputation: 57

Click on a href in VBA

I want to click on the following link

enter image description here

I have the class name and the line code I was trying ot use is the following:

objIE.document.getElementByClassName("msDataText searchLink").Click

This may well be a very basic question.. any guidance

Thanks a lot

Upvotes: 1

Views: 1069

Answers (1)

Mukul Varshney
Mukul Varshney

Reputation: 3141

Not sure if it is a duplicate question. A good function GetHTTPResult is already available from the link. You need to just pass the url for the GET request to fetch the data. For POST request (this function will not work), you need to make a POST request with postdata.

Also there is a sample for XMLHttpRequest at link

Function GetHTTPResult(sURL As String) As String
    Dim XMLHTTP As Variant, sResult As String

    Set XMLHTTP = CreateObject("WinHttp.WinHttpRequest.5.1")
    XMLHTTP.Open "GET", sURL, False
    XMLHTTP.Send
    Debug.Print "Status: " & XMLHTTP.Status & " - " & XMLHTTP.StatusText
    sResult = XMLHTTP.ResponseText
    Debug.Print "Length of response: " & Len(sResult)
    Set XMLHTTP = Nothing
    GetHTTPResult = sResult
End Function

Upvotes: 1

Related Questions