View Full Version : Export Latitude and Longitude

11-10-2009, 02:54 PM
I'm using mappoint 2006. Is there any way to export the latitude and longitude info for my pushpins matched by street address?

11-11-2009, 03:21 AM
Two possibilities

1. Invest in the excellent Pushpin Tool
Pushpin Tool: Manage your Microsoft MapPoint Pushpins (http://www.mapping-tools.com/pushpin_tool/index.shtml)

2. Run some excel vba code to export pushpin data, including latitude and longitude, into an excel worksheet. Here’s some basic code that runs on the active map that might help get you started....

Option Explicit

Private Sub ExportLatLongs_Click()
Dim objMap As MapPoint.Map
Dim objDataSet As MapPoint.DataSet
Dim objDataSets As MapPoint.DataSets
Dim objRecordSet As MapPoint.Recordset
Dim objFields As MapPoint.Fields
Dim objField As MapPoint.Field
Dim objPin As MapPoint.Pushpin
Dim objLoc As MapPoint.Location
Dim Ws1 As Excel.Worksheet
Dim PushpinSet As String
Dim NDataSets As Integer, kCount As Integer, i As Integer
Dim Lat As Double, Lon As Double
Dim booSetFound As Boolean

On Error GoTo NoActiveMap
'specify appropriate MapPoint version
Set objMap = GetObject(, "MapPoint.Application.EU.16").ActiveMap
On Error GoTo Error_handler

Set Ws1 = Sheets("Sheet1")
Ws1.UsedRange.Clear 'clear any old data

Set objDataSets = objMap.DataSets
NDataSets = objDataSets.Count
If NDataSets = 0 Then
GoTo NoDataSets
End If
'************************************************* *****************************
' Specify the pushpin set name you want the info exported for
'************************************************* *****************************
PushpinSet = "My pushpins"

booSetFound = False
For Each objDataSet In objDataSets
If objDataSet.Name = PushpinSet Then
booSetFound = True
Set objRecordSet = objDataSet.QueryAllRecords
kCount = 0
Set objFields = objRecordSet.Fields
For i = 1 To objRecordSet.Fields.Count
Ws1.Cells(1, i + 1) = objFields(i).Name
Ws1.Cells(1, 1).Value = "Pushpin Name"
Ws1.Cells(1, objFields.Count + 2).Value = "Latitude"
Ws1.Cells(1, objFields.Count + 3).Value = "Longitude"

Do Until objRecordSet.EOF
Set objFields = objRecordSet.Fields
kCount = kCount + 1

For i = 1 To objFields.Count
Ws1.Cells(kCount + 1, i + 1).Value = objFields(i).Value
Next i

Set objPin = objRecordSet.Pushpin
Set objLoc = objPin.Location
Lat = objLoc.Latitude 'Get latitude of this location
Lon = objLoc.Longitude 'Get longitude of this location
Ws1.Cells(kCount + 1, 1) = objPin.Name
Ws1.Cells(kCount + 1, objFields.Count + 2).Value = Round(Lat, 6)
Ws1.Cells(kCount + 1, objFields.Count + 3).Value = Round(Lon, 6)

End If

If booSetFound = False Then
GoTo NoPushpinSet
End If

MsgBox "Data for " & kCount & _
" pushpins in data set '" & PushpinSet & _
"' exported to excel worksheet."

GoTo Exit_handler

MsgBox "This program works on an active MapPoint map." _
& " You need to have a map open.", vbExclamation, _
"Program Ending"
GoTo Exit_handler

MsgBox "Sorry but there don't appear to be any datasets on this map.", _
vbExclamation, "Program Ending"
GoTo Exit_handler

MsgBox "There doesn't appear to be a pushpin set called " & PushpinSet & _
" on this map.", vbExclamation, "Program Ending"
GoTo Exit_handler

MsgBox "Error " & Err.Number & vbCrLf & vbCrLf & _
Err.Description, vbExclamation, "Program Ending"

Set objMap = Nothing
Set objDataSet = Nothing
Set objDataSets = Nothing
Set objRecordSet = Nothing
Set objField = Nothing
Set objFields = Nothing
Set objPin = Nothing
Set objLoc = Nothing
Set Ws1 = Nothing

End Sub

Hope that helps

07-12-2010, 04:20 PM
I know this is a bit late, but if you are looking for a freeware solution to your problem, I found one in the form of PROFIT100's program IC-DatasetExport. Unfortunately, the company is German, and I was unable to find an English version of the program. The program is very easy to work, however. Simply run the program, choose your pushpin dataset(s), and it exports wherever you want, complete with lat and long.

06-30-2011, 12:09 PM
Davidb, thank you for your EXCELLENT solution!

A few points, for anyone implementing this:
1. This VBA code could go behind a button that you put onto an Excel spreadsheet.
2. I changed Davidb's code
Set objMap = GetObject(, "MapPoint.Application.EU.16").ActiveMap
to fit my verson of MapPoint. For me, it is
Set objMap = GetObject(, "MapPoint.Application.NA.17").ActiveMap
because I'm using MapPoint North America 2010.
3. For those of you new to VBA, when you are looking at your code, you might have to add the MapPoint reference to Excel. You'll do this in Microsoft Visual Basic by going to Tools/References and selecting "Microsoft MapPoint 17 Object Library" (or whatever version you are using).

But Davidb, these are pointers for beginners, everything else was very good and very fast. Thanks!

10-27-2014, 03:46 AM
I am using MapPoint 2011 and would like to make pinpoints out of my search for "other places". Is there a function somewhere to do this? How about exporting "other places' to Excel and importing them back as data points? I can't find an export function for "other places" either.

03-11-2016, 01:54 AM
A handy way to store latitude and longitude values in Excel is to treat them as regular time values.