Open a file in word using a command button

  • Thread starter Thread starter Paul
  • Start date Start date
P

Paul

can anyone tell me if and how to make a command button
open a fle from another program like word or excel

thank you paul
 
There are a few ways of doing it. Here's how I do it :

I have a command button with the on click as follows :

Private Sub Command21_Click()
Dim strCmd As String

strCmd = """C:\Program Files\Common Files\Microsoft
Shared\PhotoEd\Photoed.exe"" " (this code is on one line)

strCmd = strCmd & """" & Me![FilePathName] & """"
Shell strCmd
End Sub

In this case I am 'shelling' to Photo Editor - but
substitute the path and folder names to winword.exe and
substitute your .doc name for [FilePathName]
 
i set it the way you said but it keeps saying it can not
find the file" run-time error 2465





-----Original Message-----
There are a few ways of doing it. Here's how I do it :

I have a command button with the on click as follows :

Private Sub Command21_Click()
Dim strCmd As String

strCmd = """C:\Program Files\Common Files\Microsoft
Shared\PhotoEd\Photoed.exe"" " (this code is on one line)

strCmd = strCmd & """" & Me![FilePathName] & """"
Shell strCmd
End Sub

In this case I am 'shelling' to Photo Editor - but
substitute the path and folder names to winword.exe and
substitute your .doc name for [FilePathName]
-----Original Message-----
can anyone tell me if and how to make a command button
open a fle from another program like word or excel

thank you paul
.
.
 
Try:

application.FollowHyperlink "c:\my documents\test.doc"


The above would open the document as if you clicked on it. The above will
work for any file that you can click on and launch.
 
Back
Top