Welcome to MapForums!

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

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

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)"

Do While Sheets("Sheet1").Cells(NReadRow, 2) <> ""

'Locate the 2 points

'Calculate the route
objRoute.Calculate

'Drive Distance in Miles
'Drive Time in Minutes
'Straight Line Distance in Miles (as a check)
objRoute.Clear

objMap.Saved = True

Loop

End Sub```

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