• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Syntax error "webservice to pull weather data using API key"

ALAMZEB

Member
Hi

I am using the sheet to update weather data through API but i get syntax error when refreshing error.
If above is solved than can i get five more cities through API, right now the API is only for one city. Code below and attached is the file
Thanks again guys, will save me a lot of time

Code:
Private Sub btnRefresh_Click()

Dim WS As Worksheet: Set WS = ActiveSheet

    WS.Range(“theDate”).Value = “”

    WS.Range(“highTemps”).Value = “”

    WS.Range(“lowTemps”).Value = “”

    Dim delShape As Shape

    For Each delShape In WS.Shapes

        If delShape.Type = msoAutoShape Then delShape.Delete

    Next delShape

    Dim Req As New XMLHTTP
  
    Req.Open “GET”, “api.worldweatheronline.com/free/v2/weather.ashx?q=Australia&format=XML&num_of_days=15&key=00057eddc240dd4452def703a9e6c;, False


    Req.send

    Dim Resp As New DOMDocument

    Resp.LoadXML Req.responseText

    Dim Weather As IXMLDOMNode

    Dim i As Integer

    Dim wShape As Shape

    Dim thisCell As Range

    For Each Weather In Resp.getElementsByTagName(“weather”)

        i = i + 1

        WS.Range(“theDate”).Cells(1, i).Value = Weather.SelectNodes(“date”)(0).Text

        WS.Range(“highTemps”).Cells(1, i).Value = Weather.SelectNodes(“tempMaxF”)(0).Text

        WS.Range(“lowTemps”).Cells(1, i).Value = Weather.SelectNodes(“tempMinF”)(0).Text

        Set thisCell = WS.Range(“weatherPictures”).Cells(1, i)

        Set wShape = WS.Shapes.AddShape(msoShapeRectangle, _

        thisCell.Left, thisCell.Top, thisCell.Width, thisCell.Height)

        wShape.Fill.UserPicture Weather.SelectNodes(“weatherIconUrl”).Item(0).Text

    Next Weather

End Sub
 

Attachments

Last edited by a moderator:

Hi !

Every codeline in red is a bad syntax line !

Start to use true doublequote for strings …
 
Back
Top