Community of MapPoint and Virtual Earth Users and Developers
This is a discussion on Placing PushPins using VBA programing within the MapPoint 2006/2009 Discussion forums, part of the Map Forums category; I am now to MapPoint automation and am in the midst of have to modify and existing MSAccess 2K application ...
| |||||||
| Today's Posts | Twitter Feed | Register | Blogs | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Click here to register |
View Poll Results: Is the Curse of the Bambino finally broken? | |||
| Yes | | 2 | 66.67% |
| No | | 1 | 33.33% |
| Voters: 3. You may not vote on this poll | |||
![]() |
| LinkBack | Thread Tools | Display Modes |
| |||
| Placing PushPins using VBA programing Read each record, place a pushpin that looks like a green factory at the location indicated by its Long and Lat values. Has anyone been able to accomplish such a task and if so, is there any example visual basic code? Any help would be greatly appreciated. Thanks jburgess |
| ||||
|
I assume you have a copy of MapPoint? Looking the help. Under programming information, there are a number of pages about how to do specific things - eg. locations, routes, polygons. Look at the locations and pushpins example. You need to create a Location object from your lat/long coordinate. Then you create a pushpin object using the Location object. You can set the symbol type or load one of your own. Richard
__________________ Winwaed Software Technology LLC http://www.winwaed.com See http://www.mapping-tools.com for MapPoint Tools See the Geoweb Guru for online mapping |
| |||
| re: Placing PushPins using VBA programing
As an aside, I find that the app is quicker if I simply save the long/lats to a CSV and load it as a dataset; otherwise, I get "the curse of the flickering hourglass" as it adds each pin in turn. Just a thought; do it any way that makes you happy |
| |||
| Placing PushPins using VBA programing
I have also a problem with setting pushpins with a vba code. At first I calculte a distance matrix and afterwards I want to add a pushpin to each of my addresses, but it doesn´t work... Here is my code: Sub Distance() Dim oApp As New MapPoint.Application oApp.Visible = True oApp.UserControl = True oApp.ActiveMap.Saved = True oApp.Units = geoKm Dim objFindResults As MapPoint.FindResults Dim objLoc As MapPoint.Location Dim objPushpin As MapPoint.Pushpin Dim i As Integer Dim j As Integer Dim PLZ1, PLZ2 As String Dim STADT1, STADT2 As String Dim ADDRESSE1, ADDRESSE2 As String Dim dist As Double Set oApp = CreateObject("MapPoint.Application") Set objMap = oApp.ActiveMap Set objRoute = objMap.ActiveRoute For i = 2 To 4 PLZ1 = Tabelle1.Cells(i, 2) STADT1 = Tabelle1.Cells(i, 3) ADDRESSE1 = Tabelle1.Cells(i, 4) For j = i + 1 To 4 PLZ2 = Tabelle1.Cells(j, 2) STADT2 = Tabelle1.Cells(j, 3) ADDRESSE2 = Tabelle1.Cells(j, 4) objRoute.Waypoints.Add objMap.FindAddressResults(PLZ1, STADT1, ADDRESSE1).Item(1) objRoute.Waypoints.Add objMap.FindAddressResults(PLZ2, STADT2, ADDRESSE2).Item(1) objRoute.Calculate 'Set objLoc = objMap.FindAddressResults(Plz1, stadt1, addresse1) 'objMap.AddPushpin (objLoc) dist = objRoute.Distance Debug.Print i & "," & j Debug.Print "distance " & dist objRoute.Clear Next j Next i oApp.Quit End Sub When I run the makro without the red pushpin part everything works great. But with that part it doesn´t work. I don´t know how to add pushpins in this case but I know that the red part works in other makros... Can anybody help me? Already thanks Kikolino |
| |||
| Re: Placing PushPins using VBA programing
Hi, You probably will have an exception if you step with the debugger trough it. FindAddressResults returns a collection of Location object, not a Location object. So something like this should work: Code: Dim objLocResults As MapPoint.FindResults; objLocResults = objMap.FindAddressResults(Plz1, stadt1, addresse1); objMap.AddPushpin(objLocResults_Item(1));
__________________ rgds, Wilfried Mestdagh www.mestdagh.biz MapPoint coding demo Order MapPoint 2009 with Routing and User Tools Spreadsheet |
| |||
| Re: Placing PushPins using VBA programing
Hi Wilfried! Thanks for your quick answer but unfortunately it doesn´t work... Even with the right syntax ![]() Set objLocResults = objMap.FindAddressResults(PLZ1, STADT1, ADDRESSE1) objMap.AddPushpin (objLocResults.Item(1)) Runtime error 438 appears. Greetz Kikolino |
| |||
| Re: Placing PushPins using VBA programing
Hi, You should first check the ResultsQuality property. Maybe there is no Location returned from that particular address. Sorry I was incomplete..
__________________ rgds, Wilfried Mestdagh www.mestdagh.biz MapPoint coding demo Order MapPoint 2009 with Routing and User Tools Spreadsheet |
| |||
| Re: Placing PushPins using VBA programing
Hi, then something else should be wrong. did you try a simple test like this? eventually with other addresses and so ? this is C# but you can easy translate it into VBA. Piece of code is tested: Code: int name = 1;
FindResults addrResults = MP.ActiveMap.FindAddressResults("churchilllaan", "Schoten", "", "", "", GeoCountry.geoCountryBelgium);
foreach (object o in addrResults) {
Location loc = o as Location;
if (loc == null)
continue;
MP.ActiveMap.AddPushpin(loc, name.ToString());
name++;
}
__________________ rgds, Wilfried Mestdagh www.mestdagh.biz MapPoint coding demo Order MapPoint 2009 with Routing and User Tools Spreadsheet |
![]() |
| Tags |
| placing, programing, pushpins, vba |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
| ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Creating a subset of Pushpins from a set of pushpins | paf33 | MapPoint 2006/2009 Discussion | 3 | 08-09-2005 04:54 AM |
| Pl.. Help ----Locating/ placing positions in India | Anonymous | MapPoint 2006/2009 Discussion | 0 | 11-13-2003 02:20 AM |
| Programmatically Placing Pushpin on a Line | jbendiner | MapPoint 2006/2009 Discussion | 0 | 01-05-2003 10:18 PM |
Thassos Holidays
Visit an unspoilt and beautiful Greek island with Thassos holidays available through UlookUbook.