MapPoint Forums

MapForums

Community of VE/MapPoint Users and Developers




How to get lat/long coordintates with VBA Excel

This is a discussion on How to get lat/long coordintates with VBA Excel within the Development forums, part of the MapPoint 2006/2009 Discussion category; Hi, I have the problem that I found an address with the FindAddressResults method and set a pushpin on that ...


Go Back   MapPoint Forums > Map Forums > MapPoint 2006/2009 Discussion > Development

Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read
  2 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old 02-06-2008
Junior Member
White Belt
 
Join Date: Feb 2008
Posts: 9
How to get lat/long coordintates with VBA Excel

Hi,
I have the problem that I found an address with the FindAddressResults method and set a pushpin on that point. What i want to know is how to get the lat/long/alt coordinates for that point automaticly via VBA Code in my excel sheet. So I have hundreds of addresses with pushpins and want to have a list with lat/long coordinates for it.

Thx right now,
Kikolino
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 02-09-2008
Senior Member
Black Belt
 
Join Date: Nov 2004
Posts: 2,055
Re: How to get lat/long coordintates with VBA Excel

Hi,

FindAddressResults returns a collection of Location and other objects. So if resultsquality is ok then loop in the result until it is a Location object. Then you can add a pushpin with that Location object and this object has also Latitude / Longitude information, so you have all you need
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 02-09-2008
Junior Member
White Belt
 
Join Date: Feb 2008
Posts: 9
Re: How to get lat/long coordintates with VBA Excel

Hi Wilfried!
Thank you for your answer. I know what you are meaning and it helped to understand the problem but I still have the problem that I donīt know how to get the lat/long by writing a VBA Code. My code is the following:

Private Sub CommandButton1_Click()
Dim objFindResults As MapPoint.FindResults
Dim objLoc As MapPoint.Location
Dim objPushpin As MapPoint.Pushpin
Dim Bereich As Range
Dim Zelle As Range

Set oApp = CreateObject("MapPoint.Application")
Set objMap = oApp.NewMap
Set objRoute = objMap.ActiveRoute

Dim nCurrentRow As Integer
nCurrentRow = 2

szAddress = Cells(nCurrentRow, 4)
Do While (szAddress <> 0)
szName = Cells(nCurrentRow, 1)
szcity = Cells(nCurrentRow, 3)
szZip = Cells(nCurrentRow, 2)
Set objFindResults = objMap.FindAddressResults(szAddress, szcity, szZip)
Set objLoc = objFindResults(1)
Set objPushpin = objMap.AddPushpin(objLoc, szName)
objPushpin.BalloonState = geoDisplayName

nCurrentRow = nCurrentRow + 1
szAddress = Cells(nCurrentRow, 4)

Loop

And now i want to get the lat/long coordinates for each pushpin and afterwards calcute the distances between them. But I donīt know how...
objPushin...
distance.calculate...
Perhaps you can help me again, that would be great!

Greetz
Kikolino
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4 (permalink)  
Old 02-11-2008
Member
Green Belt
 
Join Date: Oct 2003
Location: London
Posts: 97
Re: How to get lat/long coordintates with VBA Excel

To get the latitude and longitude I think all you need is

'Get latitude of this location
Lat = objLoc.Latitude
'Get longitude of this location
Lon = objLoc.Longitude

To get distance then calculate the route and apply

objRoute.Distance …………..for the driving distance
objRoute.DrivingTime …………….for the driving time
objMap.Distance(objLoc1, objLoc2) ………….for the straight line distance
__________________
David
MapPoint Europe Gallery at http://www.broomanalysis.plus.com/gallerylist.html

Last edited by davidb; 02-11-2008 at 07:02 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5 (permalink)  
Old 02-14-2008
Junior Member
White Belt
 
Join Date: Feb 2008
Posts: 9
Re: How to get lat/long coordintates with VBA Excel

Hi davidb!

Thanks for your help! It works now!

Greetz
Kikolino
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6 (permalink)  
Old 02-14-2008
Winwaed's Avatar
Mapping-Tools.com
Red Belt
 
Join Date: Feb 2004
Posts: 787
Blog Entries: 5
Re: How to get lat/long coordintates with VBA Excel

The Latitude and Longitude properties are only guaranteed to be set if you are working with MapPoint 2006.

Earlier versions only set these fields if the object was created with coordinates!
(search this site for "CalcPos" for a cunning solution from Gilles)


Richard
__________________
Winwaed Software Technology LLC
http://www.winwaed.com
See http://www.mapping-tools.com for MapPoint Tools
Pre-Order MapPoint 2009 today: http://www.mapping-tools.com/mappoint2009
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/how-get-lat-long-coordintates-vba-excel-7094.html

Posted By For Type Date
Working With Excel and MapPoint - MP2K Magazine This thread Refback 02-10-2008 12:27 PM
The Magazine for MapPoint - MP2K Magazine This thread Refback 02-06-2008 09:25 AM

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
Adding Lat/long to polyline from excel DeepBlue MapPoint 2006/2009 Discussion 3 05-15-2007 06:59 AM
setting up macro in excel to extract lat/long from map point TransportationNut05 MapPoint 2006/2009 Discussion 2 08-24-2005 10:45 AM
Exporting Lat/Long of State Boundaries to Excel Rpirong MapPoint 2006/2009 Discussion 2 05-12-2005 10:26 AM
Locate City and zip code using lat and long (Excel Macro) sberhe Wish List 0 04-01-2005 09:31 AM
MPControl embedded in excel - excel loses functionality ruyasan MapPoint 2006/2009 Discussion 2 05-20-2004 03:41 AM


All times are GMT -5. The time now is 06:30 PM.


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

Flight Departures
Check Holiday Hypermarket to find flight departures to numerous exotic destinations. We link to details on flight departures and arrivals to help you find information fast.

Spain Holidays
Find and book Spain Holidays with Travel Counsellors. Holiday destinations around the world including Spain.

Italy Holiday
An Italy Holiday is full of interesting stuff for the casual tourist and even more for the educated visitor. Check out the latest great deals at dealchecker.co.uk.

Holidays to Antigua
The Holiday Place has fantastic deals on holidays to Antigua. Visit our website to view special offers on holidays to the Caribbean.

Cheap Egypt Holidays
Pick up a bargain cheap Egypt holiday online when you visit ulookubook.com. Just check out our tips to make sure you book at the right time to get a great holiday for a great price. Finding cheap Egypt holidays can be simple when you know how.

Cheap Travel
For cheap travel options, visit Travel.co.uk and explore the benefits of our comparison site.

Cheap Holidays to Sharm el Sheikh
Break away to Northern Africa. Find cheap holidays to Sharm el Sheikh 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