Community of VE/MapPoint Users and Developers
This is a discussion on Distance and Time Traveled ?? within the Products: Pushpin Tool, Single State Mapper forums, part of the Map Forums category; I have about 700 sites across the country that I have in a spreadsheet. I have imported them into MP ...
| |||||||
| Register | Blogs | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||
| Distance and Time Traveled ?? Thoughts? |
| |||
| Re: Distance and Time Traveled ??
Hi there I think this is likely to be quite straightforward in Excel vba. I’m currently trying to improve my vb programming skills and used the following code for a similar application in the UK. Please note that the points were located via their postcodes and I knew all the postcodes were valid (ie. recognised by MP2006) ahead of running the program. The data was input as 2 columns in an excel worksheet with the following format Hub Satellite Locations KT17 4BT W1U7BU SY22 6AA E4 7JA BN1 4JF NW1 8HX OX29 7DX etc,etc (sorry, I can't get this table to come out in the right format. The satellite postcodes W1U7BU, SY22 6AA, BN1 4JF, NW1 8HX, OX29 7DX should all be in the second column). It ouputs drive distance, drivetime and straight-line distance to the same worksheet. This is the code I used Private Sub CommandButton1_Click() Dim objApp As New MapPoint.Application Dim objMap As MapPoint.Map Dim objRoute As MapPoint.Route Dim objLoc1 As MapPoint.Location Dim objLoc2 As MapPoint.Location Set objApp = CreateObject("MapPoint.Application.EU.13") objApp.Visible = False Set objMap = objApp.NewMap Set objRoute = objMap.ActiveRoute Worksheets("Excel Worksheet").Cells(1, 3).Value = "Drive Distance (kms)" Worksheets("Excel Worksheet").Cells(1, 4).Value = "Drive Time (mins)" Worksheets("Excel Worksheet").Cells(1, 5).Value = "Straight Line Distance (kms)" NReadRow = 2 n = 2 Do While Worksheets("Excel Worksheet").Cells(NReadRow, 2) <> "" 'Locate the 2 points Set objLoc1 = objMap.FindResults(Worksheets("Excel Worksheet").Cells(n, 1)).Item(1) Set objLoc2 = objMap.FindResults(Worksheets("Excel Worksheet").Cells(NReadRow, 2)).Item(1) 'Calculate the route objRoute.Waypoints.Add objLoc1 objRoute.Waypoints.Add objLoc2 objRoute.Calculate 'Drive Distance in kms Worksheets("Excel Worksheet").Cells(NReadRow, 3) = objRoute.Distance 'Drive Time in minutes Worksheets("Excel Worksheet").Cells(NReadRow, 4) = objRoute.DrivingTime 'Straight Line Distance in kms (as a check) Worksheets("Excel Worksheet").Cells(NReadRow, 5) = objMap.Distance(objLoc1, objLoc2) objRoute.Clear 'Assign the correct hub NReadRow = NReadRow + 1 If Worksheets("Excel Worksheet").Cells(NReadRow, 1).Value <> "" Then n = NReadRow End If Loop End Sub As I said I’m only learning so you need to treat the code with real caution; there are bound to be errors. But I hope it gets you started. By the way you’d have got better exposure of your post if you’d put it in the MapPoint Discussion Forum. Rgds, David
__________________ David MapPoint Europe Gallery at http://www.broomanalysis.plus.com/gallerylist.html Last edited by davidb; 08-29-2007 at 07:44 AM. Reason: Table comes out with wrong format |
| |||
| Re: Distance and Time Traveled ??
Thanks for the reply. (I moved the thread also). I will take a shot at putting your code in and seeing what happens. Question... I have recently been upgraded to Office 2007. Might there be an issue with using Excel VBA from 2007 then saving down to 97-2003 workbook? Thanks again David. |
![]() |
| ||||
| Posted By | For | Type | Date | |
| Travel help distance time | This thread | Refback | 11-09-2007 04:53 AM | |
| The Magazine for MapPoint - MP2K Magazine | This thread | Refback | 09-04-2007 01:59 AM | |
| Pushpin Tool Add-in - MP2K Magazine | This thread | Refback | 08-30-2007 05:10 AM | |
| Tracking P.F. Chang’s in the Midwest - MapPoint Articles - MP2K Magazine | This thread | Refback | 08-28-2007 04:28 PM | |
| Reverse Geocoding, Another Method - MapPoint Articles - MP2K Magazine | This thread | Refback | 08-28-2007 02:46 PM | |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
| ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Distance/Time between Waypoints | jasanite | MapPoint 2006/2009 Discussion | 7 | 08-18-2007 11:16 AM |
| How do you create a time to distance map? | Integraoligist | MapPoint 2006/2009 Discussion | 1 | 08-01-2007 03:52 PM |
| Distance calculation time (MP 2006) - HELP | dsia | MapPoint 2006/2009 Discussion | 3 | 06-04-2007 02:16 AM |
| Distance/Drive Time | stwilber | MapPoint 2006/2009 Discussion | 1 | 11-10-2006 10:13 AM |
| My calculations on distance and time appear to be wrong | Anonymous | MapPoint 2006/2009 Discussion | 0 | 11-27-2004 05:58 PM |
Cheap Flights to Brussels
Book cheap flights to Brussels online today. Brussels is a city with diverse culture with over 100 museums to visit and an array of different architectural designs to view.
Spain Weather
Check Spain Weather before you travel. We provide information on Spain including weather, flights and accommodation.
Cheap Holiday Turkey
Booking a cheap holiday to Turkey doesn't have to be at the expense of enjoyment. Dealchecker.co.uk searches holidays from the leading UK Tour Operators.
Egypt Holidays
Visit one of the most spectacular sightseeing destinations in the world with The Holiday Place. Egypt holidays provide a fantastic break!
Cheap Turkey Holidays
The best time of year to sneak in cheap Turkey holidays is during the off-peak season. Check out the great deals available during April, May or October. For other tips on how to bag a great value holiday simply check online at ulookubook.com
Cheap Travel
Travel.co.uk has some excellent offers on cheap travel. Click here.
Cheap Holidays to Goa
Dine on delightful seafood in west India. Find information on cheap holidays in Goa at On The Beach.