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
Results 1 to 5 of 5

Using MapPoint from Word, Access and Excel

This is a discussion on Using MapPoint from Word, Access and Excel within the MP2K Magazine Articles forums, part of the Map Forums category; This article contains code snippets that allows you to seamlessly drop a map graphic into your Word, Access or Excel ...

  1. #1
    Anonymous is offline Senior Member Black Belt
    Join Date
    Jul 2002
    Posts
    5,137

    Using MapPoint from Word, Access and Excel

    This article contains code snippets that allows you to seamlessly drop a map graphic into your Word, Access or Excel documents anywhere you have a valid address.

    Read the full article: http://www.mp2kmag.com/articles.asp?ArticleID=39

  2. #2
    Anonymous is offline Senior Member Black Belt
    Join Date
    Jul 2002
    Posts
    5,137

    Using MapPoint from Word, Access and Excel

    when creating the macro, I get the compile error message "User defined type not defined". I am using Word 2000 and Mappoint 2000.

  3. #3
    Anonymous is offline Senior Member Black Belt
    Join Date
    Jul 2002
    Posts
    5,137

    Re: Using MapPoint from Word, Access and Excel

    Quote Originally Posted by macd
    when creating the macro, I get the compile error message "User defined type not defined". I am using Word 2000 and Mappoint 2000.
    Sorry, my version of Mappoint is 2002. The line in the module is 'Dim oApp As MapPoint.Application'

  4. #4
    Anonymous is offline Senior Member Black Belt
    Join Date
    Jul 2002
    Posts
    5,137

    Using MapPoint from Word, Access and Excel

    Nevermind, I didn't have the proper references checked. Works pretty good! I was wondering, do you know of a more general script that will work with any highlighted text? Or of a macro that will autolauch Mappoint with the address in highlighted? Thanks.

  5. #5
    Anonymous is offline Senior Member Black Belt
    Join Date
    Jul 2002
    Posts
    5,137
    I had some difficulty with acCmdPaste in the Access app. I can get it to run just fine in Access 97, but it usually won't paste in Access 2002. When this happens the app locks up until I give it the 3 finger salute. I've fixed the lockups with error handling. I've also added an API to do the pasting. This usuall (but not always) works. Here's my modifications:

    Private Sub cmdMap_Click()
    Dim oApp As Object, oMap As Object, oPush(1 To 2) As Object, oLoc(1 To 2) As Object

    Set oApp = CreateObject("Mappoint.Application")
    Set oMap = oApp.NewMap

    Set oLoc(1) = oMap.Find(Address & " , " & City & " , " & State)
    Set oLoc(2) = oMap.Find(Address2 & " , " & City2 & " , " & State2)
    If Not oLoc(1) Is Nothing Then
    Set oPush(1) = oMap.AddPushpin(oLoc(1))
    oPush(1).GoTo

    If Not IsNull(MyName) Then oPush(1).Name = MyName
    oPush(1).Highlight = True

    If Not oLoc(2) Is Nothing Then
    Set oPush(2) = oMap.AddPushpin(oLoc(2))

    oPush(2).Highlight = True

    With oMap.ActiveRoute
    .Waypoints.Add oLoc(1)
    .Waypoints.Add oLoc(2)
    .Calculate
    End With
    'oMap.CopyDirections
    'txtDir.SetFocus
    'RunCommand acCmdPaste

    ' substituting these lines
    oMap.CopyDirections
    DoEvents
    Me.txtDir.SetFocus
    Me.txtDir = GetData()
    Else
    txtDir.SetFocus
    txtDir.Text = "No second location found!"
    End If

    oMap.DataSets(1).ZoomTo
    oMap.CopyMap
    imgClip.Visible = True
    imgClip.Action = acOLEPaste

    lblMapInfo.Caption = ""
    Else
    lblMapInfo.Caption = "Address Not Found!"
    End If

    ' Take these out
    'Set oMap = Nothing
    'Set oApp = Nothing
    'Me.SetFocus
    'End Sub


    'Then add error handling
    Exit_Here:
    Set oMap = Nothing
    oApp.Quit
    Set oApp = Nothing
    Me.SetFocus
    Exit Sub

    Error_Handler:
    MsgBox Err.Number & ": " & Err.Description
    Resume Exit_Here

    End Sub


    Unfortunately oApp.Quit opens MapPoint, but it does keep an instance from running in memory, which I believe is the reason it won't always paste.

    The API is at:

    http://support.microsoft.com/?id=138910

    and I rewrote the Clipboard_GetData() function similar to Dev Ashish's code at: http://www.mvps.org/access
    --
    Arvin Meyer, MVP
    Microsoft Access

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Pasting a Mappoint Legend into MS Word 2003
    By Eric B in forum Wish List
    Replies: 0
    Last Post: 08-18-2005, 04:44 PM
  2. Cut and Paste Problem with Word 2003 and MapPoint 2004
    By brubli in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 10-21-2004, 05:26 PM
  3. Mail Merge using MapPoint 2004 and Word 2003
    By fibble9 in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 04-14-2004, 05:29 PM
  4. When working with mappoint and coping to word how ....
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 06-28-2002, 09:20 AM
  5. 10 Second Tutorial: Embedding With Word
    By Anonymous in forum MP2K Magazine Articles
    Replies: 0
    Last Post: 07-01-2001, 12:48 AM

Tags for this Thread

Posting Permissions

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


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96