print word document

  • Thread starter Thread starter JIM
  • Start date Start date
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
 
Back
Top