print word document

J

JIM

Hi, using code found on-line I'm trying to print a word document in a report.
I get a run time error #424 saying "object required". My document prints
well though. What I would like to do is instead of hard coding the location
as in C:\Wordtest.doc, can the file location be taken from a field from the
query the report is based on? I've tried using the field name but don't know
the syntax.
Appreciate any help,
JIM

Private Sub Report_Open(Cancel As Integer)
PrintDoc() = True
End Sub
Function PrintDoc()
Dim WordObj As Object
Set WordObj = CreateObject("Word.Application")
WordObj.Documents.Open "C:Wordtest.doc"
WordObj.PrintOut Background:=False
WordObj.Quit
Set WordObj = Nothing
End Function
 

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