Hi all,
I apologize for bothering you, but I hope you're the one to help me get out of this mess.
I have the following situation:
First of all, I want to mention that I am a user of mac (big sur) and implicitly of excel for mac (excel 365 - version 16.49).
- In column A I have the start coordinates (lat, long)
- in column B the arrival coordinates. (lat, long)
I want to put through a VBA Macro.
- in column C to calculate the distance by driving in kilometers
- in column D the time traveled by car between the two locations.
The service I want to use is the Bing Map API. I have a valid API key.
After a long research I found that it is not going to do this on poppy seeds. I tested it on windows and it's ok but it doesn't work on mac.
Can you please help me with rewriting the code below to work on Mac as well?
Thanks,
Adrian
here is the code:
Public Function GetDistance(start As String, dest As String)
Dim firstVal As String, secondVal As String, lastVal As String
firstVal = "
https://dev.virtualearth.net/REST/v1/Routes/DistanceMatrix?origins="
secondVal = "&destinations="
lastVal = "&travelMode=driving&o=xml&key=My_API_KEY&distanceUnit=mi"
Set objHTTP = CreateObject("MSXML2.ServerXMLHTTP")
Url = firstVal & start & secondVal & dest & lastVal
objHTTP.Open "GET", Url, False
objHTTP.setRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"
objHTTP.send ("")
GetDistance = Round(WorksheetFunction.FilterXML(objHTTP.responseText, "//TravelDistance"), 0) & " miles"
End Function
Public Function GetTime(start As String, dest As String)
Dim firstVal As String, secondVal As String, lastVal As String
firstVal = "
https://dev.virtualearth.net/REST/v1/Routes/DistanceMatrix?origins="
secondVal = "&destinations="
lastVal = "&travelMode=driving&o=xml&key=My_API_KEY&distanceUnit=mi"
Set objHTTP = CreateObject("MSXML2.ServerXMLHTTP")
Url = firstVal & start & secondVal & dest & lastVal
objHTTP.Open "GET", Url, False
objHTTP.setRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"
objHTTP.send ("")
GetTime = Round(WorksheetFunction.FilterXML(objHTTP.responseText, "//TravelDuration"), 0) & " minutes"
End Function