Closing Running Processes

G

Guest

I have an Access application that need to close any non-visible instances of
Word running in the background. This is to tidy up any Word objects that have
been left behind. Any visible instances of Word must be left open. In
essence, the VBA equivalent of 'End Process' on Winword instances in Windows
Task Manager.

I can close all instances using GetObject to grab Word then quit but this
also quits visible instances. My coding for this is:

On Error GoTo Word_Is_Closed
Word_Close:
Set oWord = GetObject(, "Word.Application")
oWord.Activate
oWord.Quit
Set oWord = Nothing
GoTo Word_Close
Word_Is_Closed:

Anyone any ideas?

Thanks.

BW
 
S

Stefan Hoffmann

hi,
I can close all instances using GetObject to grab Word then quit but this
also quits visible instances. My coding for this is:

On Error GoTo Word_Is_Closed
Word_Close:
Set oWord = GetObject(, "Word.Application")
oWord.Activate
oWord.Quit
Set oWord = Nothing
GoTo Word_Close
Word_Is_Closed:

Anyone any ideas?
If Not oWord.Visible Then oWord.Quit?


mfG
--> stefan <--
 
G

Guest

Thanks Stefan

Your coding was my original solution but it doesn't work as, if Word is
visible, the same instance of Word is grabbed next time around - an endless
loop.

I can't see how to progress from one Word instance to another.

BW
 

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