Microsoft KB Archive/277749

= How To Set a Pushpin in MapPoint 2001 Using Automation =

Article ID: 277749

Article Last Modified on 2/12/2007

-

APPLIES TO


 * Microsoft Visual Basic 5.0 Professional Edition
 * Microsoft Visual Basic 6.0 Professional Edition
 * Microsoft Visual Basic 5.0 Enterprise Edition
 * Microsoft Visual Basic 6.0 Enterprise Edition
 * Microsoft MapPoint 2001 Standard Edition

-



This article was previously published under Q277749



SUMMARY
This article describes how to use MapPoint 2001 to find an address and set a pushpin at that address.



MORE INFORMATION
To find an address and set a pushpin at that address:  On a computer with MapPoint 2001 installed, create a new Visual Basic Standard EXE project. Form1 is created by default. On the Project menu, click References. Click to select the Microsoft MapPoint Object Library 8.0 (North America) check box, and then click OK. On Form1, add a Command button.  In the code window of Form1, paste the following code: Option Explicit

Dim objApp As MapPoint.Application Dim objMap As MapPoint.Map Dim objLoc As MapPoint.Location Dim objPushpin as MapPoint.Pushpin

Private Sub Command1_Click ' Automate MapPoint. ' Start MapPoint 2001. Set objApp = CreateObject(&quot;mappoint.application&quot;) ' Get the currently displayed map. Set objMap = objApp.ActiveMap ' Find an address. Set objLoc = objMap.FindAddress(&quot;One Microsoft Way&quot;, &quot;Redmond&quot;, &quot;Washington&quot;, &quot;98052&quot;, geoCountryUnitedStates) ' Set a pushpin at the address. Set objPushpin = objMap.AddPushpin(objLoc, &quot;Microsoft&quot;) ' Browse to the pushpin. objPushpin.GoTo ' Highlight the pushpin. objPushpin.Highlight = True ' Show MapPoint. objApp.Visible = True End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer) ' Clear the variables before you unload the form. Set objMap = Nothing Set objApp = Nothing Set objLoc = Nothing Set objPushpin = Nothing End Sub  Run the project. Click Command1.</li></ol>

A pushpin in MapPoint marks the address you specified.

<div class="references_section">