Welcome to MapForums!

Register, sign in, or use Facebook Connect above to join in and participate in the forum.

When you are signed in, this message, the ads in this row, and the red-underlined link ads all go away.

Subscribe to receive our newsletter.
Subscribe Unsubscribe
Results 1 to 2 of 2

Distance Calculator Runs Slowly

This is a discussion on Distance Calculator Runs Slowly within the Development forums, part of the MapPoint Desktop Discussion category; I have a macro in which I can input a start and end postcode, then let MapPoint find the drive ...

  1. #1
    nickshep85 is offline Junior Member Yellow Belt
    Join Date
    May 2010
    Posts
    13

    Distance Calculator Runs Slowly

    I have a macro in which I can input a start and end postcode, then let MapPoint find the drive time and distance and return it in my spreadsheet. My issue is that I am currently using this to find 300+ distances and the macro is running very slow, sometimes taking up to 60 seconds to return one result.

    Can anyone help me try to speed this up in any way?

    I'm using Windows XP, Excel 2003 and MapPoint Europe 2011.

    Thanks for your help.


    Code:
    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")
    objApp.Visible = False
    
    
    Set objMap = objApp.NewMap
    Set objRoute = objMap.ActiveRoute
    Sheets("Sheet1").Cells(1, 3).Value = "Drive Distance (Miles)"
    Sheets("Sheet1").Cells(1, 4).Value = "Drive Time (Mins)"
    Sheets("Sheet1").Cells(1, 5).Value = "Straight Line Distance (Miles)"
    NReadRow = 2
    
    
    Do While Sheets("Sheet1").Cells(NReadRow, 2) <> ""
    
    
    'Locate the 2 points
    Set objLoc1 = objMap.FindResults(Sheets("Sheet1").Cells(NReadRow, 1)).Item(1)
    Set objLoc2 = objMap.FindResults(Sheets("Sheet1").Cells(NReadRow, 2)).Item(1)
    
    
    'Calculate the route
    objRoute.Waypoints.Add objLoc1
    objRoute.Waypoints.Add objLoc2
    objRoute.Calculate
    
    
    'Drive Distance in Miles
    Sheets("Sheet1").Cells(NReadRow, 3) = objRoute.Distance
    'Drive Time in Minutes
    Sheets("Sheet1").Cells(NReadRow, 4) = objRoute.DrivingTime
    'Straight Line Distance in Miles (as a check)
    Sheets("Sheet1").Cells(NReadRow, 5) = objMap.Distance(objLoc1, objLoc2)
    objRoute.Clear
    
    
    NReadRow = NReadRow + 1
    
    
    objMap.Saved = True
    
    
    Loop
    
    
    End Sub

  2. #2
    Winwaed's Avatar
    Winwaed is offline Mapping-Tools.com Black Belt
    Join Date
    Feb 2004
    Location
    Irving,Texas
    Posts
    1,859
    Blog Entries
    60

    Re: Distance Calculator Runs Slowly

    I don't see anything obvious, so it could be a combination of your PC being old (you're running XP and Excel 2003 which suggests an older and possibly overloaded PC); the locations, and their positions.

    Try separating the geocoding out - this could be adding to the time.
    Or use an existing off-the-shelf solution (eg. our MPMileage product at MPMileage: Batch calculate mileages with Microsoft MapPoint ). Yes it costs but you save the time developing on a discontinued product.
    Winwaed Software Technology LLC
    http://www.winwaed.com
    See http://www.mapping-tools.com for MapPoint Tools

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Calculate the route runs so slow
    By davidxuwg in forum Development
    Replies: 2
    Last Post: 10-13-2010, 08:57 AM
  2. Replies: 0
    Last Post: 05-20-2010, 04:28 AM
  3. New Bing Map Apps: Gas Prices, Distance Calculator and Parking Finder
    By VirtualEarth MSDN Blog in forum Bing Maps Blogs & Tweets
    Replies: 0
    Last Post: 05-19-2010, 04:11 PM
  4. UK postcode distance calculator
    By coolguyfru in forum Other Mapping Platforms
    Replies: 2
    Last Post: 06-16-2009, 09:20 AM
  5. How do you scroll slowly?
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 5
    Last Post: 12-17-2004, 04:44 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127