How To Automate MapPoint 2000 from Visual Basic (236615)



The information in this article applies to:

  • Microsoft MapPoint 2000
  • Microsoft Visual Basic Professional Edition for Windows 5.0
  • Microsoft Visual Basic Professional Edition for Windows 6.0
  • Microsoft Visual Basic Enterprise Edition for Windows 5.0
  • Microsoft Visual Basic Enterprise Edition for Windows 6.0

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

  1. Start Visual Basic and create a new standard EXE project.

    Form1 is created by default.
  2. Add a Command button to Form1.
  3. Click References on the Project menu to bring up the References dialog box.
  4. Add a reference to the Microsoft MapPoint 1.0 Object Library and then click OK to close the References dialog box.
  5. 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
    					
  6. 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:

Modification Type:MinorLast Reviewed:8/23/2005
Keywords:kbAutomation kbhowto KB236615 kbAudDeveloper