mercredi 21 novembre 2018

VBA Adjustment for adaptablity

I have this code I would like to rewrite to get the Bid price from yahoo. The code currently gets the Last price, however I would like to get the Bid price and if the Bid price is zero, then get the last price. I tried exhaustively to rewrite it myself but was not successful. Can someone assist in my quest to rewrite this code.

Thank you kindly

Sub GetRate() Dim XMLPage As New MSXML2.XMLHTTP60 Dim htmlDoc As New MSHTML.HTMLDocument Dim URL As String Dim HTMLspans As MSHTML.IHTMLElementCollection Dim HTMLspan As MSHTML.IHTMLElement

URL = "https://finance.yahoo.com/quote/AAP181221C00170000?p=AAP181221C00170000"

XMLPage.Open "GET", URL, False
XMLPage.send

htmlDoc.body.innerHTML = XMLPage.responseText

Set HTMLspans = htmlDoc.getElementsByTagName("span")

For Each HTMLspan In HTMLspans
    If HTMLspan.className = "Trsdu(0.3s) Fw(b) Fz(36px) Mb(-4px) D(ib)" Then
        debug.Print HTMLspan.innerText
    End If
Next HTMLspan

End Sub




Aucun commentaire:

Enregistrer un commentaire