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
Page 2 of 2 FirstFirst 12
Results 11 to 14 of 14

Getting Distances

This is a discussion on Getting Distances within the MapPoint Desktop Discussion forums, part of the Map Forums category; It works really good, I made some changes to be able to work with other countries and also I added ...

  1. #11
    cmarquez is offline Junior Member White Belt
    Join Date
    Oct 2006
    Posts
    8

    Re: Getting Distances

    It works really good, I made some changes to be able to work with other countries and also I added this to end the mappoint

    oApp.ActiveMap.Saved = True
    oApp.Quit
    Set oApp = Nothing

    But how I can do to have more than 25 rows??? because it works really good until row 25 but after that it show me a bug

    Thanks

  2. #12
    cmarquez is offline Junior Member White Belt
    Join Date
    Oct 2006
    Posts
    8

    Re: Getting Distances

    Well this is the final code I have, the only thing is that I can't make the process for more than 25 row, do you know how I can do it?

    The code

    Dim oApp As MapPoint.Application
    Private Sub CommandButton1_Click()
    Set oApp = CreateObject("MapPoint.Application.EU")
    oApp.Visible = False
    Set objMap = oApp.NewMap
    Set objRoute = objMap.ActiveRoute
    Dim nCurrentRow As Integer
    nCurrentRow = 3

    Dim Code1, Code2 As String
    Dim objFindResults As MapPoint.FindResults


    Do While Len(Worksheets("Sheet1").Cells(nCurrentRow, 6)) <> 0


    Code1 = Worksheets("Sheet1").Cells(nCurrentRow, 3)
    Code2 = Worksheets("Sheet1").Cells(nCurrentRow, 6)

    On Error Resume Next

    If Code1 = ", " Then Exit Do


    Set objFindResults = objMap.FindResults(Code1)
    objRoute.Waypoints.Add objFindResults(1)
    Set objFindResults = objMap.FindResults(Code2)
    objRoute.Waypoints.Add objFindResults(1)



    objRoute.Calculate
    On Error GoTo 0
    Worksheets("Sheet1").Cells(nCurrentRow, 7) = objRoute.Distance
    Worksheets("Sheet1").Cells(nCurrentRow, = CStr(objRoute.TripTime / geoOneMinute)

    objRoute.Clear
    nCurrentRow = nCurrentRow + 1



    Loop

    oApp.ActiveMap.Saved = True
    oApp.Quit
    Set oApp = Nothing



    End Sub

  3. #13
    cmarquez is offline Junior Member White Belt
    Join Date
    Oct 2006
    Posts
    8

    Re: Getting Distances

    It was just a wrong zip code, but this code works really good, thanks a lot for your help

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

    Re: Getting Distances

    Terrific, I'm glad you got it to work and I like your modifications.

    Please tell other people about this forum and link to it

    Check on row 25 (or the row above or below) and put those postal codes directly into MapPoint manually, one of them must not be found i.e. MapPoint cannot find one of them.

    Do either or both of the following
    1. find a nearby postal code and fix it on the spreadsheet to be a zip code MapPoint can find..
    2. place something in to code so that when it doesn't find a postal code it skips that line. I don't have the MapPoint Help File in front of me but it would be something like If objFindResults.Count = 0 then [SKIP TO NEXT ROW]. Maybe there is no objFindResults.Count property or anything like but, but that would be the logic anyway.

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

Page 2 of 2 FirstFirst 12

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Excel UDF to calculate distances using lat/lon
    By pherrero in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 01-10-2010, 10:15 PM
  2. Calculate distances
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 11-18-2004, 11:58 AM
  3. Batch Distances?!
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 01-21-2004, 01:40 PM
  4. Distances Between Push Pins
    By Ravi1 in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 10-21-2003, 07:32 PM
  5. hi, we are using mappoint to get distances for ou....
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 3
    Last Post: 07-05-2002, 11:01 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