Open a Word Document from a command Button

G

Guest

I have created a new command button on a form which I would like to open a
word document with. This is the code I have put in when creating the
cmdButton

Private Sub cmdReport1_Click()
On Error GoTo Err_cmdReport1_Click

Dim oApp As Object

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

Exit_cmdReport1_Click:
Exit Sub

Err_cmdReport1_Click:
MsgBox Err.Description
Resume Exit_cmdReport1_Click

End Sub


This opens word like a dream but how do I point it to my document so that
when the application opens it opens with the document.

For this exercise lets just say the document name I wish to open is TEST.DOC
and is located at c:\database\word\TEST.DOC.

Thanks in advance and I am going to post this same message in Forms coding
as I am not sure which group to go to on this question.
 
G

Guest

Slow Learner said:
I have created a new command button on a form which I would like to open a
word document with. This is the code I have put in when creating the
cmdButton

Private Sub cmdReport1_Click()
On Error GoTo Err_cmdReport1_Click

Dim oApp As Object

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

Exit_cmdReport1_Click:
Exit Sub

Err_cmdReport1_Click:
MsgBox Err.Description
Resume Exit_cmdReport1_Click

End Sub


This opens word like a dream but how do I point it to my document so that
when the application opens it opens with the document.

For this exercise lets just say the document name I wish to open is TEST.DOC
and is located at c:\database\word\TEST.DOC.

Thanks in advance and I am going to post this same message in Forms coding
as I am not sure which group to go to on this question.
 

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