After .PrintOut, Word remains in Task Manager

K

kiln

I'm using code like the following to print out a Word 2000 doc via MS
Access 2000. Probably because Word is still spooling the print job, the
..Close code below seems to not remove the word instance. Is there a good
way to kill the word instance if it's done?

Private Sub cmdPrint_Click()
Dim objWord As Object

strFilePath = "c:\some.doc"
Set objWord = CreateObject("Word.Application")
' open some other doc so this background job can complete.
objWord.Documents.Add "c:\someother.doc"
objWord.PrintOut Background:=False, FileName:=strFilePath

ExitHere:
On Error Resume Next
objWord.Close
Set objWord = Nothing
Exit Sub

End Sub
 
J

Jonathan West

You're using the wrong method name for closing Word.

You need this instead

objWord.Quit SaveChanges:=0

This will close Word, closing any open documents without saving them.
 
J

Jezebel

This line is wrong, too

objWord.Documents.Add "c:\someother.doc"

You should be opening the document, not creating a new one. As it is, you're
creating a new document ostensibly using the existing one as a template.
 
K

kiln

You're using the wrong method name for closing Word.

You need this instead

objWord.Quit SaveChanges:=0

This will close Word, closing any open documents without saving them.
Thanks!
 
K

kiln

That code was taken from a place where I am printing a larger set of
docs as a background job. It may not be approp. here but in the orig
case PrintOut needed a doc (any doc) to be open for the routine to
follow through. I'll revise to the simpler route, thanks
 
K

kiln

Hi, thanks...is .Application valid when using late binding? If so that
is interesting.
 

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