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
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 ...
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
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'Originally Posted by macd
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.
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
There are currently 1 users browsing this thread. (0 members and 1 guests)