JEG said:
Thank you Jay.
I have another question. I am trying to have users be able to print
out a file based on the options button they click. How can I have a
file printout without opening the file? Is there a simple print
command where I can just say like "print file c:\abc.doc" or
something? I would rather the files not be opened to print them. I
can only seem to do the macro if the files are opened and then
printed.
Thanks!
Jackie
Hi Jackie,
You can't print a document without opening it at all, but that doesn't mean
it has to appear on screen. The expression Visible:=False in the Open
command below will prevent the document from showing while it prints, and it
will close immediately afterward.
The expression Background:=False tells VBA to wait until Word has sent the
whole document to the spooler before going on to the Close command, rather
than doing "background printing" and immediately continuing (that would
cause Word to pop up the message "Word is still printing, do you want to
close anyway?").
Dim oDoc As Document
Set oDoc = Documents.Open(FileName:="lorem2.doc", Visible:=False)
With oDoc
.PrintOut Background:=False
.Close SaveChanges:=wdDoNotSaveChanges
End With