Hello, I am trying to automate mappoint in VBA to find the street distances and times between two Lat/Lon locations. The assumption can be made that the variables for input are dblOriginLat, dblOriginLon, dblDestLat, dblDestLon. Ideally the output would be something along the lines of dblMiles and dblTime (in minutes). I will be running this within a loop so I need to do this in such a way that the "Route" is cleared after every two points so it can be run multiple times.
I have found this code but not sure how to clear the Routes afterwards nor how to use it with Lat/Lon.
Function MPRouteDist(iMPType As Integer, ParamArray WPoints())
Dim objApp As New MapPoint.Application
Set objMap = objApp.ActiveMap
For Each wpoint In WPoints
.Waypoints.Item(1).SegmentPreferences = iMPType
MPRouteDist = Application.Round(CStr(.Distance), 5)
objMap.Saved = True