Printing a Word Document from Access 2003

K

Kedd123

The following code works the first (or first few) times:

Dim oApp As Object
Set oApp = CreateObject("Word.Application")
oApp.Documents.Open "Drive and Filename"
oApp.PrintOut
oApp.Documents.Close
oApp.Quit
Set oApp = Nothing

but at some point the following message box begins appearing:

File in Use
File.doc is locked for editing by 'userid'
Do you want to:
Open a read only copy
Create a local copy and merge your changes later
Receive notification when the original copy is availabe

When Open a read only copy is chosen the "save as" dialog box appears as
well as another Access message box stating the file is read only.

I have verified the file is NOT open by looking in the folder using explorer
and looking for a "lock" file.

My goal is to print the document without any of these dialog boxes
appearing. I would like to print the file without running the word
application and opening the file, but I do not know how to do write that code.

Any help is greatly appreciated!
 
A

Albert D. Kallal

You can use:

CreateObject("Shell.Application").Namespace(0).ParseName("c:\mypdf\myDoc.doc").InvokeVerb
("&Print")

The problem here is then word launches...and starts to print the above....

If you try and print the same doc AGAIN, word may not have finished printing
the above.
but at some point the following message box begins appearing:

The question is are you printing just one doc, or "many". If your printing
many, then I don't suggest the above.

I would also consider changing:

oApp.Documents.Close
to

oApp.Documents.Close (False)

It is entirely possible that your document is being modified somehow, and
the above says to not save any changes. Regardless there is no need to save
the document, and the above says don't save the document when you close.
(the above suggestion is a bit of a long shot on my part, since if the
docment not been modified, then I don't think closing will actually save the
document again, but it might....).

Tt's just not clear how many times your printing the document over and over.
 

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