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 12 of 12

VBA To Find Nearest Custom Location

This is a discussion on VBA To Find Nearest Custom Location within the MapPoint Desktop Discussion forums, part of the Map Forums category; I have to admit it's not going too well at the moment. I'm no further through this code than when ...

  1. #11
    nickshep85 is offline Junior Member Yellow Belt
    Join Date
    May 2010
    Posts
    13

    Re: VBA To Find Nearest Custom Location

    I have to admit it's not going too well at the moment. I'm no further through this code than when I started this thread!

    It really doesn't help that this is the first time that I've tried to use VBA! If I could figure out how to make MapPoint locate a postcode and then the three nearest custom places/pushpins I'd be very happy. But alas, I can't. At least, not yet! Once I get that part sorted I think I will automate a Vlookup to get the Centre Type.

    See, I have the vision and the ideas, just not the knowledge to make these ideas become reality!!

  2. #12
    nickshep85 is offline Junior Member Yellow Belt
    Join Date
    May 2010
    Posts
    13

    Re: VBA To Find Nearest Custom Location

    I've been looking at my code for this for ages now and have made a slight breakthrough - but I still need plenty of help!!!!!

    I've found that my custom pushpins for my Centres are in the DataSets object in VBA, so at least now I know where they are in MapPoint.

    However, I still cannot get my head around how to find a location and then show the nearest Centre in my spreadsheet.

    Below is my updated code, which probably isn't much different from the original, but I am very much a beginner at this.

    Any help is very much appreciated.

    Code:
    Sub FindNearbyPlaces()
    
    Dim objApp As New MapPoint.Application
    Dim objMap As MapPoint.Map
    Dim objRoute As MapPoint.Route
    Dim objNearby As MapPoint.Waypoint
    Dim objLoc As MapPoint.Location
    
    Set objApp = CreateObject("Mappoint.Application.EU.13")
    objApp.Visible = False
    Set objMap = objApp.OpenMap("C:\Program Files\Microsoft MapPoint Europe\Centres By Type.ptm", False)
    
    
    'Insert Column Headers
    Sheets("Sheet1").Cells(1, 2).Value = "Nearest Centre"
    Sheets("Sheet1").Cells(1, 3).Value = "Centre Type"
    Sheets("Sheet1").Cells(1, 4).Value = "2nd Nearest Centre"
    Sheets("Sheet1").Cells(1, 5).Value = "Centre Type"
    Sheets("Sheet1").Cells(1, 6).Value = "3rd Nearest Centre"
    Sheets("Sheet1").Cells(1, 7).Value = "Centre Type"
    NReadRow = 2
    
    Do While Sheets("Sheet1").Cells(NReadRow, 2) <> ""
    
    'Locate Start Point
    Set objLoc = objMap.FindResults(Sheets("Sheet1").Cells(NReadRow, 1)).Item(1)
    
    'Find Nearest Centre and Show Results In Spreadsheet
    Sheets("Sheet1").Cells(NReadRow, 2) = objMap.DataSets.Item(1).Name
    
    
    NReadRow = NReadRow + 1
    
    Loop
    
    
    
    End Sub

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. Find the nearest address.
    By VC_Man in forum MapPoint Desktop Discussion
    Replies: 4
    Last Post: 02-28-2007, 02:58 AM
  2. Custom location returns null when using find nearby in route
    By briansbrown in forum MapPoint Desktop Discussion
    Replies: 2
    Last Post: 11-15-2005, 02:40 PM
  3. find nearest locality
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 07-09-2003, 04:26 AM
  4. How to find nearest city?
    By Petr Brant in forum MapPoint Desktop Discussion
    Replies: 3
    Last Post: 08-23-2002, 02:49 PM
  5. Find address of location
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 08-23-2002, 11:11 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