dimanche 1 mars 2015

Excel and MapQuest API

MapQuest has changed their XML file and I'm no longer able to retrieve the distance and the time.


My VBA script is hung up on the following:



Private Sub GetDistance_MapQuest(ByVal startFrom As String, ByVal endAt As String, ByRef refMiles As Double, ByRef refHours As Double)

Dim url As String
Dim resp As String

Dim req As MSXML2.XMLHTTP
Dim xdoc As MSXML2.DOMDocument

url = "http://ift.tt/1zwbAkK"
url = url & "&from=" & Replace(Trim(startFrom), " ", "%20")
url = url & "&to=" & Replace(Trim(endAt), " ", "%20")

Set req = New MSXML2.XMLHTTP
req.Open "GET", url, False
req.send

resp = req.responseText

Set xdoc = req.responseXML

refMiles = CSng(xdoc.SelectSingleNode("response / route / distance").Text)
refHours = CLng(xdoc.SelectSingleNode("response / route / time").Text) / 60 / 60


The script stops on


req.send


and says the system cannot locate the resource specified. It worked previously. Does anyone have an idea how I can correct this?


Aucun commentaire:

Enregistrer un commentaire