Open program file via access form button

B

Barry

Thanks for the help. I don't think my earlier question was clear enough. I
have a microsoft mapping program called MapPoint. It resides in C:\Program
Files\MapPoint. From that Mapping program I have made various Map Files:
MyMap.ptm, Arizona.ptm, PA.ptm, California.ptm, etc. the path to these files
are c:\MyMap.ptm, c:\Arizona.ptm, etc.

How do I make a button for each file that will open them? Example a button
to open MyMap, another button to open Arizona, etc.

Every thing I have tried so far only opens the executable MapPoint Program.
I'd like to open particular files.

Can anyone help Please?

Thanks in advance
 
A

Arvin Meyer [MVP]

You can use ShellExecute to open a file:

http://www.mvps.org/access/api/api0018.htm

But I'll do you 1 better. MapPoint is a Microsoft Office VBA client. Here's
some code that will open a map inside an Access form and plot a map with
directions between 2 addresses. The map is displayed in a Bound Object frame
(objMap):

Private Sub cmdMap_Click()
Dim oApp As Object
Dim oMap As Object
Dim oPush(1 To 2) As Object
Dim 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
DoEvents
Me.txtDir.SetFocus
DoCmd.RunCommand acCmdPaste
Else
txtDir.SetFocus
txtDir.Text = "No second location found!"
End If

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

lblMapInfo.Caption = ""
Else
lblMapInfo.Caption = "Address Not Found!"
End If
Set oMap = Nothing
Set oApp = Nothing
Me.SetFocus
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top