Sub GetMapsDistances()
Dim xhrRequest As XMLHTTP60
Dim domDoc As DOMDocument60
Dim ixnlDistanceNodes As IXMLDOMNodeList
Dim ixnNode As IXMLDOMNode
Dim TtlDist As Long
' Donated to MrExcel users by diddi
' Read the data from the website
Set xhrRequest = New XMLHTTP60
xhrRequest.Open "GET", "http://maps.googleapis.com/maps/api/directions/xml?origin=" & ComboBox2.Value & "&destination=" & ComboBox3.Value & "&sensor=false", False
xhrRequest.send
Set domDoc = New DOMDocument60
domDoc.loadXML xhrRequest.responseText
Set ixnlDistanceNodes = domDoc.selectNodes("//step/distance/value")
' Total up the distance from node to node
TtlDist = 0
For Each ixnNode In ixnlDistanceNodes
TtlDist = TtlDist + Val(ixnNode.Text)
Next ixnNode
Label13.Caption = "One way distance is about " & Int(TtlDist / 1000) & "km"
Label14.Caption = "Return trip is about " & Int(TtlDist * 2 / 1000) & "km"
Set ixnNode = Nothing
Set ixnlDistanceNodes = Nothing
Set domDoc = Nothing
Set xhrRequest = Nothing
End Sub