Loking for a way to close Word

O

Oscar

In order to close MS Word after some automation routines I use the following
code

On Error Resume Next
objword.ActiveDocument.Close savechanges:=0
On Error Resume Next
objword.Quit
On Error Resume Next
Set objword = Nothing


While this has worked for older versions of Word, it doesn't work for Word
200(2) as I can see that the process remains in the tasklist of the Windows
task manager. What is a better way to force a Word document and the Word
application to close ?

regards,
Oscar
 
J

Jezebel

First, remove the 'on error' statements -- if these instructions are causing
errors you need to know about it. (In any case, there's no need to repeat
the 'On error' -- it applies to ALL following statements until you give some
other on error instruction.)

If Word is refusing to shut down following this sequence, then there is
something else going on -- such as another document open with unsaved
changes, or an unhandled error from earlier in your code.
 
O

Oscar

thanks Jezebel,

Yes you are right about the situation that there might be a document open
with unsaved changes. Since that I've apllied the
only-read=true at the opening of the document, the Word object is deleted
from the task list succesfully.

regards,
Oscar
 

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