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

## Version 2001 Programatic manipulation

This is a discussion on Version 2001 Programatic manipulation within the MapPoint Desktop Discussion forums, part of the Map Forums category; I have MapPoint 2001, Can I manipulate this w/ VB(A) to retrieve the Lat, Lon, Distance, route Milesage etc. I ...

1. Senior Member Black Belt
Join Date
Jul 2002
Posts
5,137

## Version 2001 Programatic manipulation

I have MapPoint 2001, Can I manipulate this w/ VB(A) to retrieve the Lat, Lon, Distance, route Milesage etc. I am reasonably proficient w/ the various'flavors" of VB(A) and VB itself, but have noted the numerous recommendations to upgrade to at least ver "X" (all well beyond 2001). Unfortunatly, I would be hard pressed to afford the cost as I am retired and have a limited income. The obnly 'reference' I see within the help files concerns generating a com add in to instantiate as a menu item. It doesn't even begin to list the data elements which could then be manipulated via the menu item (re the above)

2. Senior Member Black Belt
Join Date
Jul 2002
Posts
5,137

## Response?

Since the original posting, I have struggled to get through the exercise. I have browsed through over 1/2 of the messages and articles posted here in, extracting several to numerous routines and combining them with the (skimpy?) examples from (MapPoint) Help. The Calc Position routine with some help file stufff ... ffff gets a map open (even on screen! - Which I do not really need), and -given a LITERAL for the place to find setting a location object, it will return (calculate) a (single) Lat & Lon. I cannot sem to devise any way to have FIND use a calculated string or string variable. If any one can suggest WHAT the (*&!#\$^(*&#^\$(A@^( I am doing wrong it would be SISNCERELY appreciated. It would be almost sincerely appreciated If you could even DEFINITIVELY state that Find CANNOT accept anything BUT the literal argument (although THAT seems to make the method of the object USELESS!!!! (?)

Code:
```Public Function basOpenMap&#40;MapPath As String&#41; As Boolean

'Michael Red    11/5/04 First try from Help Exapmples

Dim objMapApp As MapPoint.Application
Dim objMap As MapPoint.Map
Dim objRs As MapPoint.Recordset
Dim objData As MapPoint.DataSet
Dim objLoc As MapPoint.Location
Dim PPinLoc As MapPoint.Location
Dim ILat As Double
Dim iLon As Double

Set objMapApp = New MapPoint.Application
Set objMap = objMapApp.NewMap
Dim Idx As Integer

objMap.SaveAs objMapApp.DefaultFilePath & "\Map.Ptm", geoFormatMap

objMapApp.NewMap
Set objMap = objMapApp.OpenMap&#40;objMapApp.DefaultFilePath & "\" & MapPath & ".PTM"&#41;
Set objRs = objMapApp.OpenMap&#40;objMapApp.DefaultFilePath & "\" & MapPath & ".PTM"&#41; _
.DataSets&#40;"qrySelFlZips"&#41;.QueryAllRecords
Set objData = objMap.DataSets&#40;"qrySelFlZips"&#41;
objData.DisplayPushpinMap

'From LITERAL ONLY
Set objLoc = objMap.Find&#40;"Tampa, FL"&#41;
Call CalcPos&#40;objMap, objLoc, ILat, iLon&#41;        '<-Works
Debug.Print ILat, iLon

'From ana attempt to get the several via the string VARIABLE
While Idx < objData.RecordCount
Set PPinLoc = objMap.Find&#40;Chr&#40;34&#41; & objRs.Fields&#40;1&#41; _
& ", FL" & Chr&#40;34&#41;&#41;

Call CalcPos&#40;objMap, PPinLoc, ILat, iLon&#41;   '<-Works NOT
Debug.Print objRs.Pushpin.Name, objRs.Fields&#40;1&#41;, ILat, iLon     'Gives Zip Code &#40;PK&#41; and Name
objRs.MoveNext

Idx = Idx + 1
Wend

End Function```

3. Its good advice to upgrade to MapPoint 2002. It will be frustrating trying to get stuff to work and it will be hard to help you with 2001. (I don't even have a copy anymore I dont think) Everyone uses 2002 or 2004. The big difference in 2004 is updated data. You may be able to get a copy of MapPoint 2002 on ebay for a good price.

I did notice in you code sample that you opened/created the map 4 times?

Code:
```Set objMap = objMapApp.NewMap
objMapApp.NewMap
Set objMap = objMapApp.OpenMap&#40;objMapApp.DefaultFilePath & "\" & MapPath & ".PTM"&#41;
Set objRs = objMapApp.OpenMap&#40;objMapApp.DefaultFilePath & "\" & MapPath & ".PTM"&#41; _ .DataSets&#40;"qrySelFlZips"&#41;.QueryAllRecords```

4. Senior Member Black Belt
Join Date
Jul 2002
Posts
5,137
John,

Thanks for at least SOME response. By continued 'due duilengence', I am (S L O W L Y) getting somewhere. I can currently ge a large percentage of the points to work with a string variable using the FIND method. Approx 15% still baffle me. Using the "Find Dialog, I can enter the City name and State and ye olde (and apparently decripit?) MapPoint 2001 goes to the city. Putting the "Same" info in programatically with the string variable, the Finf METHOD fails to generate a Location object. I think much of my earlier difficulty in the use of the string var was the weird, non-standard error handling from MapPooint (at least ver '01). When the methods fail, they do not error, but set the opbject to nothing, but the Distance method fails and returns an actual error. I did eventually find [/b]Is Nothing and can trap the occurance of the failure to find and prevent (ByPass) the call to CalcPos.

Alas. Alack and Awry I still can't figure out WHY the find method fails -particularly so often. My first thought was that find was not able to (uniquely) resolve the City-State in htese instances, however using hte text box entry shows tha somewhere over (or at least near) 90% of hte entries return multiple locations, so this appears to not be the basic issue. I haven't yet attempted to Include the Zip code as part of location to Find, however this would be -at best- problematical, as Zip Codes are subject to change and I do not seem to have a reliable (and FREE) source enyway. I MAY go back and re-try t he FinAddress method, but so far at least is is even MORE frostrating than Find, as it SEEMS LIKE the "Street" argument is required. This might be good for a greater level of detail, but I'm only trying to get a general set of locations (to Zip code today, perhaps to census tracts later), not specific street addresses (e.g. not a single building), so I do not even have street names, or bulding / lot information to try this with.

I am just starting to manipulate MapPoint, and the code I posted is the progressive results of attempting to combine the various snippets from MApPoing (programming) help (Properties and Methods). I haven't quite yet slowed down enough to get the understanding of the differences in the various methods of instantiating the specific Map. I will review the code a bit and see if I can reduce the number of occurances of instantiating map, In particular, I would like to avoid instantiating the application as a visible object (Window), ofr at least destroy it when the routine(s) are complete.

Thanks, again, for responmding,

Michael Red

#### Thread Information

##### Users Browsing this Thread

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

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•