KnowledgeBase Archive

An Archive of Early Microsoft KnowledgeBase Articles

View on GitHub

Q236615: HOWTO: Automate MapPoint 2000 from Visual Basic

Article: Q236615
Product(s): Microsoft Automap
Version(s): 1.0,5.0,6.0
Operating System(s): 
Keyword(s): kbAutomation kbVBp500 kbVBp600 kbGrpDSO kbDSupport
Last Modified: 14-SEP-2001

-------------------------------------------------------------------------------
The information in this article applies to:

- Microsoft MapPoint 2000 
- Microsoft Visual Basic Professional Edition for Windows, versions 5.0, 6.0 
- Microsoft Visual Basic Enterprise Edition for Windows, versions 5.0, 6.0 
-------------------------------------------------------------------------------

SUMMARY
=======

This article demonstrates how to automate Microsoft MapPoint 2000 from Microsoft
Visual Basic to find an address and add a pushpin at that address.

NOTE: The sample code 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.
  Add a reference to the Microsoft MapPoint 1.0 Object Library. Click OK to
  close the References dialog box.

4. 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

5. Press the F5 key to run the project. When you press the Command button, you
  will see MapPoint start and put a highlighted pushpin at Microsoft.

REFERENCES
==========

For more information on Office Automation, please visit the following Microsoft
Office Development support site:

  http://support.microsoft.com/support/officedev/

(c) Microsoft Corporation 1999, All Rights Reserved.
Contributions by Mark Durrett, Microsoft Corporation


Additional query words:

======================================================================
Keywords          : kbAutomation kbVBp500 kbVBp600 kbGrpDSO kbDSupport 
Technology        : kbVBSearch kbAudDeveloper kbHomeProdSearch kbZNotKeyword6 kbZNotKeyword2 kbVB500Search kbVB600Search kbVB500 kbVB600 kbMapptSearch kbMapPoint2000
Version           : :1.0,5.0,6.0
Issue type        : kbhowto

=============================================================================

THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Copyright Microsoft Corporation 1986-2002.