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

Getting PostalCode/City from latitude/longitude in excel?

This is a discussion on Getting PostalCode/City from latitude/longitude in excel? within the Development forums, part of the MapPoint Desktop Discussion category; I have rows and coloums of latitude and longitude values in my excel sheet. And I need to get the ...

  1. #1
    rassbech is offline Junior Member White Belt
    Join Date
    Jan 2014
    Posts
    1

    Getting PostalCode/City from latitude/longitude in excel?

    I have rows and coloums of latitude and longitude values in my excel sheet. And I need to get the location (PostalCode and City) from these values from MapPoint down to my Excel sheet by using some VBA coding.

    I know how to get the calculated distances etc based on the coordinates, but I am having a hard time getting the Postal Code and City from the respective coordinates.

    I know I have to use the classes; StreetAddress.PostalCode; but it keeps spamming me with errors etc.

    This is my code so far (without my failure attempts for the Postals/Cities):

    Code:
    Sub Coordinates_Mappoint_VBA()
    Dim APP As New MapPoint.Application
    Dim MAP As MapPoint.MAP
    Dim RTE As MapPoint.Route
    Dim row As Integer
    
    Set MAP = APP.ActiveMap
    APP.Visible = True
    APP.UserControl = True
    MAP.Parent.PaneState = geoPaneRoutePlanner
    
    Set RTE = MAP.ActiveRoute
    RTE.Clear
    
    row = 5
    Do While Cells(row, 2) <> ""
        RTE.Clear
        LatX = Cells(row, 1).Value
        LongX = Cells(row, 2).Value
        LatY = Cells(row, 5).Value
        LongY = Cells(row, 6).Value
        
    With RTE.Waypoints
        Dim locX As MapPoint.Location
        Dim locY As MapPoint.Location
        Set locX = MAP.GetLocation(LatX, LongX)
        .Add locX
        Set locY = MAP.GetLocation(LatY, LongY)
        .Add locY
    End With
    
    RTE.Calculate
    Worksheets("GPS Makro").Cells(row, 9) = RTE.Distance
    row = row + 1
    Loop
    
    End Sub
    If anyone has a smart way to do it, I would be very happy
    Last edited by Eric Frost; 01-27-2014 at 12:15 PM.

  2. #2
    Eric Frost's Avatar
    Eric Frost is offline Administrator Black Belt
    Join Date
    Jul 1992
    Posts
    5,094
    Blog Entries
    4

    Re: Getting PostalCode/City from latitude/longitude in excel?

    I don't think you'll be able to use StreetAddress since it's not a matched address location.

    Take a look at ObjectsFromPoint. I did a couple projects for people in the last year and it worked fairly well.

    I think I was going to write an article showing some examples but never got around to it.

    If you are interested, we could use some of your example data to show how to effectively use ObjectsFromPoint, what do you think?

    Eric
    ~ Order MapPoint MapPoint 2013 Here and Get Free Access to the MapForums Downloads ~
    ~~
    ~ Upgrade to Get Access to the MapForums Downloads ~

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Latitude and Longitude
    By vanitang in forum MapPoint Desktop Discussion
    Replies: 5
    Last Post: 02-28-2011, 09:34 AM
  2. country & city information based on latitude & longitude
    By harshaghanta in forum Bing Maps and MapPoint Web Service
    Replies: 0
    Last Post: 10-22-2009, 01:43 PM
  3. How to get latitude and longitude
    By ma2005pp in forum MapPoint Desktop Discussion
    Replies: 3
    Last Post: 09-28-2005, 02:57 AM
  4. Latitude and Longitude
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 11-25-2003, 01:52 PM
  5. NMEA latitude/longitude and mappoint latitude/longitude
    By muurman in forum MapPoint Desktop Discussion
    Replies: 3
    Last Post: 11-22-2003, 05:42 AM

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