From an Access Button trying to open a Word Document

G

Guest

Hello all,

I have a button on my form from which I would like to open up a word
document. The word document would be located in a folder in the same level as
the database. Is it possible to do this?

I noticed with the button wizard you can create a button which opens up
word, but is there any way to open up a specific document? The code for the
button created by the wizard which opens up word is (I think):

Private Sub openDoc_Click()
On Error GoTo Err_openDoc_Click

Dim oApp As Object

Set oApp = CreateObject("Word.Application")
oApp.Visible = True

Exit_openDoc_Click:
Exit Sub

Err_openDoc_Click:
MsgBox Err.Description
Resume Exit_openDoc_Click

End Sub

Many thanks in advance,

Adam
 
R

Regan via AccessMonster.com

Adam said:
Hello all,

I have a button on my form from which I would like to open up a word
document. The word document would be located in a folder in the same level as
the database. Is it possible to do this?
Private Sub openDoc_Click()
On Error GoTo Err_openDoc_Click

Dim strfile AS String

strfile = "C:\PathToFile\MyWordDoctoOpen.doc"

Application.FollowHyperlink strfile

Exit_openDoc_Click:
Exit Sub

Err_openDoc_Click:
MsgBox Err.Description
Resume Exit_openDoc_Click

End Sub

Hope thats what your looking for.
 

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