At this point, I'd be happy if this would return anything other than:
Public Function GoogleDistance(FromAddress As String, ToAddress As String) As String Dim strMyKey as string Dim sXMLURL As String Dim objXMLHTTP As MSXML2.ServerXMLHTTP On Error GoTo ProcError strMyKey = "aaaa" '<= this is not the actual key sXMLURL = "https://maps.googleapis.com/maps/api/distancematrix/xml?" _ & "origin=" & Replace(Replace(FromAddress, " ", " "), " ", "+") & "&" _ & "destination=" & Replace(Replace(ToAddress, " ", " "), " ", "+") & "&" _ & "key=" & strKey ' & "sensor=False" & "&" Debug.Print sXMLURL Set objXMLHTTP = New MSXML2.ServerXMLHTTP With objXMLHTTP .Open "Get", sXMLURL, False .setRequestHeader "content-Type", "application/x-www-form-URLEncoded" .send End With Debug.Print objXMLHTTP.responseText ProcExit: Exit Function ProcError: Debug.Print Err.Number, Err.Description MsgBox Err.Number & vbCrLf & Err.Description Resume ProcExit End Function
I'm sure it is something simple in the formatting of the request string, maybe a comma, a space or something else. The data I'm testing it with generates the following string:
<?xml version="1.0" encoding="UTF-8"?> <DistanceMatrixResponse> <status>INVALID_REQUEST</status> </DistanceMatrixResponse>
Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.
”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.