Access and Word

L

LDanix

I'm am trying to get a button on a form to open a Word document. I works in
one database, but not in a second that has tables linked to the first. Both
databases are accessing the same .doc, at different times. Here's my code for
the button on the second database:

Private Sub cmdGenerateAddressList_Click()
Dim wordDoc As String
Dim oapp As Object

Set oapp = CreateObject(Class:="Word.Application")

oapp.Visible = True
wordDoc = filePath & "CurrentEmployeeAddressListPam.doc"
oapp.Documents.Open FileName:=wordDoc
End Sub

The debugger highlights "oapp.Documents.Open FileName:=wordDoc"

What am I doing wrong?

Thanks
 
L

LDanix

Yes:

Run-time error '5174':

This file could not be found.
Try one or more of the following:
* Check the spelling of the name of the document
* Try a different file name.
(CurrentEmployeeAddressListPam.doc)
 
D

Douglas J. Steele

Where are you defining filePath? Does filePath &
"CurrentEmployeeAddressListPam.doc" exist?
 

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