Send Automation print Command to Word

B

Bob W

I wish to print out a blank Word form calling from MSAccess. I do not want
the form opened for input. I am using the following code.
Dim ObjWord as Word.document
Set objWord = getObject("C:\form.doc")

if the next line is - "objWord.Application .Visible = True"- I get the
image so I know I have the document, but I prefer not to show the image as
it requires closing etc. That is not what I want.

if the next line is - "objWord.Application.Printout" - I get an error
message on the printout lie 'Server threw an exception'

What should be the code following Set objWord = ..... to drive the word
document directly to the printer?? Help needed
 
B

Brendan Reynolds

This worked for me ...

Public Sub TestWord()

Dim doc As Object

Set doc = GetObject("c:\usenet\test.doc")
doc.Activate
doc.Application.PrintOut

End Sub
 
B

Bob W

Thanks- It works I get confused by the type of object being opened.
Sometimed Doc is dimensioned as a word.doc, sometimes as a word.application
and then your idea as an object. Only yours accepted "...printout,"
 
B

Brendan Reynolds

I don't think that was the issue here. I'm not an expert at programming
Word, so I could be wrong about this, but this is what I *think* was
happening. Calling the PrintOut method without specifying any of the
optional arguments prints the active document. But until we called the
Activate method, there *was* no active document.

We might have been able to achieve the same result without calling Activate
by passing arguments to the PrintOut method. But I have not tested that.
 

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