What I'm trying to do is have Excel interface with MapPoint (v17 - 2010) in order to automatically work out drive times between two grid references. However, while the code below works perfectly if I have 2 postcodes, if I try it with grid refs instead it gives me the error: "The requested member of the collection does not exist. Use a valid name or index number".
![]()
Dim objApp As New MapPoint.Application Dim objMap As MapPoint.Map Dim objRoute As MapPoint.Route Set objMap = objApp.NewMap Set objRoute = objMap.ActiveRoute objApp.Visible = True objApp.UserControl = True szZip1 = Range("e5").Value szZip2 = Range("I5").Value 'Add route stops and calculate the route objRoute.Waypoints.Add objMap.FindResults(szZip1).Item(1) objRoute.Waypoints.Add objMap.FindResults(szZip2).Item(1) objRoute.Calculate objMap.Saved = True Range("L1").Value = CStr(objRoute.DrivingTime / geoOneMinute)
The problem is I only have one postcode, the second data source is worked out from looking up the northing and easting (grid ref) of a number of postcodes from a database I have (yep, of 1.7 million postcodes and their grid refs) and taking the average.....but I have no way to convert back the other way.
So.....I either need someone to tell me how I can get the above code working with grid refs instead of postcodes or a way to get the nearest postcode from a grid ref. Any ideas?
Bookmarks