Access form button that will open a PARTICULAR file

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? I AM A NOVICE, so please make it simple for me.

All I need is a simple button that can open a PARTICULAR FILE. I will
rewrite other buttons so as to open other files once I’ve been pointed in the
right direction.

Thanks in advance!
 
B

billybanter67

I use this code to open up a PDF, if you play around you might be able
to addapt this.

Private Sub PDFOpen_Click()
Dim varRet
Dim stPath As String
Dim strJobNumber
strJobNumber = Me.JobNumber

Set fs = Application.FileSearch
With fs
.LookIn = Me.PDFDirectory
.FileName = Me.JobNumber & ".pdf"
If .Execute > 0 Then
'MsgBox "There were " & .FoundFiles.Count & _
'" file(s) found."
For i = 1 To .foundfiles.Count
'MsgBox .FoundFiles(I)
stPath = .foundfiles(i)
varRet = fHandleFile(stPath, WIN_NORMAL)
Next i
Else
MsgBox "There were no files found."
End If


End With


Exit_PDFOpen_Click:
Exit Sub

Err_PDFOpen_Click:

Resume Exit_PDFOpen_Click:

End Sub
 
A

Albert D. Kallal

It takes one line of code.

Use:

application.FollowHyperlink "path name to file"

So:

application.FollowHyperlink "c:\Arizona.ptm"

I'm really at a loss as to why people are posting all kinds of complicated
codes and libraries when you can use a simple elegant ONE line of code for
your solution.
 
T

tish

See, this answer is beautiful to me... And I tried it BUT it's only opening
the folder that the file is in, and not the file/program itself..!? Can
anyone tell me what I'm doing wrong?? Will the code below change if there are
spaces anywhere in the path (folder and file names?) And this should be
pasted into the "event procedure" on click of the button, right?
 
T

tish

Argh. Power of posting, as they say. I realized I was making a simple/stupid
mistake.

Thanks!!
 

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