Opening a specific Word file

G

Guest

I am trying to link my Access database to specific Word file so that word
opens in the file.

The address of the word file is contained within the field called [Details]

I have tried the following, I am just learning VBA, but it will not work,
can you assist?

Private Sub Open_Property_File_Click()
On Error GoTo Err_Open_Property_File_Click

Dim stAppName As String

stAppName = "winword.exe Me![Details].Visible = True"
Call Shell(stAppName, 1)

Exit_Open_Property_File_Click:
Exit Sub

Err_Open_Property_File_Click:
MsgBox Err.Description
Resume Exit_Open_Property_File_Click

End Sub
 
G

Guest

Hi,
you can just use the followhyperlink method:

Application.FollowHyperlink Me.Details

HTH
Good luck
 
G

Guest

Try using FollowHyperlink to open the word file, and I assume that the
Details field include also the Doc name with the extention (doc)

Private Sub Open_Property_File_Click()
On Error GoTo Err_Open_Property_File_Click

Dim stAppName As String

If Not IsNull(Me![Details]) And Me![Details] = "" Then
stAppName = Me![Details]
Application.FollowHyperlink stAppName
Else
MsgBox "No doc specified"
End If

Exit_Open_Property_File_Click:
Exit Sub

Err_Open_Property_File_Click:
MsgBox Err.Description
Resume Exit_Open_Property_File_Click

End Sub
 
D

Douglas J Steele

As Oliver's pointed out, you can (and probably should) use the
FollowHyperlink method.

However, to answer your specific question, you need to put the reference to
the control that contains the file location outside of the quotes. However,
since the file location could include embedded blanks, you need to put
quotes around the file itself. The ".Visible = True" is incorrect.

stAppName = "winword.exe " & Chr$(34) & Me![Details] & Chr$(34)
 

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

Similar Threads


Top