Launching Word from access 2k

baloos

Registered User.
Local time
Today, 00:49
Joined
Dec 1, 2002
Messages
21
Hi,

I need to open a Word document from my Access 2k application. If I use the Shell function, it seems that I must specify the Path to Winword. My app may be installed on other computers where the Winword path wont always be the same.

Is there a way of executing Word (where ever it is) or of extracting the path to Winword somehow.

Any advise would be appreciated.
 
If you wish to open specific documents, and have their details stored in a table containing document name and filepath, then you can use the following from a command button on your form:

The details below show how to Open the Word application and view the document specified in the associated record on the form.

Paste the following code into a module:

'------------------Code Start-----------------------
Sub OpenWordDoc(strDocName As String)
Dim objApp As Object

'Opens the document

Set objApp = CreateObject("Word.Application")
objApp.Visible = True
objApp.Documents.Open strDocName
End Sub
'------------------Code End-----------------------

Then from the On Click event of the command button on the form (named cmdOpenWordDoc in this example) paste the following (where Me.FilePath is the name of the control on the form storing the path to the associated file):


'------------------Code Start-----------------------
Private Sub cmdOpenWordDoc_Click()
'Check to see that there is a document file path associated with the record
If IsNull(Me.FilePath) Or Me.FilePath = "" Then
MsgBox "Please Ensure There Is A File Path Associated For This Document", vbInformation, "Action Cancelled"
Exit Sub
Else
'Check that the document specified in the file path is actually there
If (Dir(Me.FilePath) = "") Then
MsgBox "Document Does Not Exist In The Specified Location", vbExclamation, "Action Cancelled"
Exit Sub
Else
'Opens document in Word
Call OpenWordDoc(Me.FilePath)
End If
End If
End Sub
'------------------Code End-----------------------

HTH

Graham
 
Try...

Application.FollowHyperlink "X:\My Documents\Word\YourFile.doc"

HTH
 

Users who are viewing this thread

Back
Top Bottom