Article ID: 236615
Article Last Modified on 8/23/2005
APPLIES TO
- Microsoft MapPoint 2000 Standard Edition
- 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
This article was previously published under Q236615
SUMMARY
This article demonstrates how to automate Microsoft MapPoint 2000 from Microsoft Visual Basic to find an address and to add a pushpin at that address.
Note The sample code that is included in this article only works with MapPoint 2000. The Visual Basic Object Model has changed in MapPoint 2001.
MORE INFORMATION
Building the Automation Sample
- Start Visual Basic and create a new standard EXE project.
Form1 is created by default. - Add a Command button to Form1.
- Click References on the Project menu to bring up the References dialog box.
- Add a reference to the Microsoft MapPoint 1.0 Object Library and then click OK to close the References dialog box.
Insert the following code in the code window for Form1:
Option Explicit Private Sub Command1_Click() ' Declare variables Dim oApp As MapPoint.Application Dim oMap As MapPoint.Map Dim oPush As MapPoint.Pushpin ' Create an instance of MapPoint. Set oApp = CreateObject("MapPoint.Application") ' Add a new map. Set oMap = oApp.NewMap ' Find a specific address. oMap.Find ("1 Microsoft Way, Redmond, WA") ' Select the pushpin at the above address. Set oPush = oMap.FindPushpin("1 Microsoft Way") ' Go to that pushpin, change its name, and highlight it. oPush.GoTo oPush.Name = "Microsoft" oPush.Highlight = True ' Release references. Set oPush = Nothing Set oMap = Nothing Set oApp = Nothing End Sub
- Press F5 to run the project.
When you click the Command button, you see MapPoint start and then put a highlighted pushpin at Microsoft.
REFERENCES
For additional information, click the following article number to view the article in the Microsoft Knowledge Base:
305200 How To Automate MapPoint by Using Visual Basic. NET
For more information on Office Automation, visit the following Microsoft Office Development Support Web site:
Keywords: kbhowto kbautomation KB236615