Welcome to MapForums!

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

Newbie needs help calculating distance

This is a discussion on Newbie needs help calculating distance within the MapPoint Desktop Discussion forums, part of the Map Forums category; Hello all. I stumbled across this forum while looking for MapPoint help on the web. I am trying to come ...

1. Junior Member White Belt
Join Date
Nov 2005
Posts
1

Newbie needs help calculating distance

Hello all. I stumbled across this forum while looking for MapPoint help on the web. I am trying to come up with a way to access MapPoint (2001) via a function in an Excel module and calculate the distance between locations in two different cells. I can use the Distance method in conjunction with GetLocation method only if I start with lat,long,alt. Problem is, I want to use city,state,country and this seems to require the Find method. Is there a way to work around this? Thanks for any ideas that you can offer. Here is a general idea. strPoint1 and strPoint2 will eventually be Excel cell addresses. Thanks, Tom

Function StraightLineDist(strPoint1, strPoint2)
Dim objApp As New MapPoint.Application
Dim objMap As MapPoint.Map
Dim objLoc(1 To 4) As MapPoint.Location

Dim dblDistance As Double

Set objMap = objApp.NewMap

'Get two known locations
Set objLoc(3) = objMap.Find("Seattle, WA, United States") 'Seattle, WA
Set objLoc(4) = objMap.Find("Redmond, WA, United States") 'Redmond, WA

Set objLoc(1) = objMap.GetLocation(47.75399, -121.97436, 100) 'Seattle, WA
Set objLoc(2) = objMap.GetLocation(47.6779, -122.11032, 100) 'Redmond, WA

'Retrieve the distance
StraightLineDist = objMap.Distance(objLoc(1), objLoc(2))

End Function

2. Senior Member Black Belt
Join Date
Nov 2004
Location
Belgium
Posts
2,433
Hi,

This article http://www.mp2kmag.com/articles.asp?...xtract.lat.lon describes how to calculate coordinates from a location object. I think this is what you need.