Here is the code you want to make. Understand that Google has some requirements or restrictions for using the API. You must use the results obtained here on Google Map. Please read our usage restrictions here: https://developers.google.com/maps/documentation/directions/
Please note that this requires a reference to "Microsoft XML, v6.0" unless you change the code to use late binding.
Dim sXMLURL As String
sXMLURL = "http://maps.googleapis.com/maps/api/directions/xml?origin=NY,+NY&destination=Los+Angeles,+CA&sensor=false"
Dim objXMLHTTP As MSXML2.ServerXMLHTTP
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
Dim domResponse as DOMDocument60
Set domResponse = New DOMDocument60
domResponse.loadXML objXMLHTTP.ResponseText
Dim ixnStatus
Set ixnStatus = domResponse.selectSingleNode("//status")
If ixnStatus.Text = "OK" Then
Dim ixnDistance, ixnDuration
Set ixnDistance = domResponse.selectSingleNode("/DirectionsResponse/route/leg/distance/text")
Set ixnDuration = domResponse.selectSingleNode("/DirectionsResponse/route/leg/duration/text")
Debug.Print "Distance: " & ixnDistance.Text 'Miles
Debug.Print "Duration: " & ixnDuration.Text 'Days Hours Minutes
End If
Set domResponse = Nothing
Set objXMLHTTP = Nothing
XML JSON, VBA JSON, . , , VBJSON, , JSON. , XML "" ( ), , Access VBA.