MS Word Printing Object problem

A

Al

I am printing an MS Word document from MS Access, below is my code.
Development is in Office 2002, my users are using Office 2000. I have set a
reference to the Microsoft Word Object Library 10.0 in my 2002 Access;
however, my Office 2000 users use Microsoft Word Object Library 9.0. To work
around this I have taken the reference out totally and wish to use
late-binding.

The process opens the Word document, populates and updates the fields just
fine. The problem is with the “.ActiveDocumentPrintOut†object (reference **
in the code). I receive Error No: 2465; Description: can’t find the field
‘|’ referrenced in your expression. I believe this is referring to the
output file name. I’m sure this is a syntax problem.

What is the correct syntax for the .ActiveDocument.PrintOut object? This
expression worked fine with the MS Word Object Library 10.0 or 9.0 reference
turned on.

Is there any other efficiencies I should be aware of?

ACCESS CODE FOLLOWS:

‘DECLARE VARS
Dim appWord As Object
Dim Docs As Object

‘SET MS WORD VARIABLES
strSched = "C:\Templates\Document.dot"
strOutputFileName="C:\Distill\in\" + strFileName + ".ps"

‘OPEN MW WORD AND DOCUMENT
Set appWord = GetObject(, "Word.Application")
Set Docs = appWord.Documents
Docs.Add strSched

‘UPDATE FIELDS IN MS WORD, PRINT DOCUMENT, CLOSE DOCUMENT
With appWord
strActPrinter = .ActivePrinter
.ActivePrinter = "PScript on FILE:"
.ActiveDocument.Fields.Update “PROCESS GETS THIS FAR CORRECTLYâ€

** .ActiveDocument.PrintOut Background:=True,
OutputFileName:=strOutputFileName, Copies:=1, Printtofile:=True, Collate:=True

.ActiveDocument.Close wdSaveChanges = False
.ActivePrinter = strActPrinter
End With

‘QUITE MS WORD AND RESET DIM VARS
appWord.Quit
Set appWord = Nothing
Set Docs = Nothing

Thanks for your assistance!!
 

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