MapPoint Forums

MapForums

Community of VE/MapPoint Users and Developers




Distance and Time Traveled ??

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 ...


Go Back   MapPoint Forums > Map Forums > Products: Pushpin Tool, Single State Mapper

Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read
  5 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old 08-28-2007
Junior Member
White Belt
 
Join Date: Aug 2007
Posts: 3
Distance and Time Traveled ??

I have about 700 sites across the country that I have in a spreadsheet. I have imported them into MP 2004 and they actually all show up. I would like to know if there is an automated way to determine the distance and time between about 50 of these sites (hubs) and the rest of them based on which hubs are designated to support which sites? I would then like to export all of the info back into excel for analysis.

Thoughts?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #2 (permalink)  
Old 08-29-2007
Member
Green Belt
 
Join Date: Oct 2003
Location: London
Posts: 92
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3 (permalink)  
Old 08-29-2007
Junior Member
White Belt
 
Join Date: Aug 2007
Posts: 3
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply


LinkBacks (?)
LinkBack to this Thread: http://www.mapforums.com/distance-time-traveled-6191.html

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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

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


All times are GMT -5. The time now is 08:19 AM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5
MP2K Magazine
Visitor Map

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.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53