Problem Prining word document from Access

S

Shannon

I have the following code which prints a word document from an Access form.
It works fine but I end up with an instance of winword.exe staying open every
time the code is run. If anyone can tell me what I am missing I would
greatly appreciate it.

Dim objApp As Object
Dim objDoc As Object

If Me![Notice] = "Yes" Then
Set objApp = CreateObject("Word.Application")
Set objDoc = objApp.Documents.Open("c:\notice.doc")
objDoc.PrintOut
objDoc.Close
Set objDoc = Nothing
Set objApp = Nothing
End If
 
B

Brendan Reynolds

I haven't been able to reproduce this - your original code does not leave an
instance of Word open on my system - so I can't say for sure whether this
will solve your problem or not, but you could try calling the Quit method of
the Word Application object ...

Set objDoc = Nothing
objApp.Quit '<--- new code here
Set objApp = Nothing
 
B

Brendan Reynolds

Oops! On closer examination I see that I was mistaken, the original code
*was* leaving an instance of Word in memory. Calling Quit does appear to
solve the problem.

--
Brendan Reynolds
Access MVP


Brendan Reynolds said:
I haven't been able to reproduce this - your original code does not leave
an instance of Word open on my system - so I can't say for sure whether
this will solve your problem or not, but you could try calling the Quit
method of the Word Application object ...

Set objDoc = Nothing
objApp.Quit '<--- new code here
Set objApp = Nothing

--
Brendan Reynolds
Access MVP

Shannon said:
I have the following code which prints a word document from an Access
form.
It works fine but I end up with an instance of winword.exe staying open
every
time the code is run. If anyone can tell me what I am missing I would
greatly appreciate it.

Dim objApp As Object
Dim objDoc As Object

If Me![Notice] = "Yes" Then
Set objApp = CreateObject("Word.Application")
Set objDoc = objApp.Documents.Open("c:\notice.doc")
objDoc.PrintOut
objDoc.Close
Set objDoc = Nothing
Set objApp = Nothing
End If
 
S

Shannon

Thanks Brendan

Brendan Reynolds said:
Oops! On closer examination I see that I was mistaken, the original code
*was* leaving an instance of Word in memory. Calling Quit does appear to
solve the problem.

--
Brendan Reynolds
Access MVP


Brendan Reynolds said:
I haven't been able to reproduce this - your original code does not leave
an instance of Word open on my system - so I can't say for sure whether
this will solve your problem or not, but you could try calling the Quit
method of the Word Application object ...

Set objDoc = Nothing
objApp.Quit '<--- new code here
Set objApp = Nothing

--
Brendan Reynolds
Access MVP

Shannon said:
I have the following code which prints a word document from an Access
form.
It works fine but I end up with an instance of winword.exe staying open
every
time the code is run. If anyone can tell me what I am missing I would
greatly appreciate it.

Dim objApp As Object
Dim objDoc As Object

If Me![Notice] = "Yes" Then
Set objApp = CreateObject("Word.Application")
Set objDoc = objApp.Documents.Open("c:\notice.doc")
objDoc.PrintOut
objDoc.Close
Set objDoc = Nothing
Set objApp = Nothing
End If
 

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