[AccessD] Getting ALL word instances

John W. Colby jwcolby at colbyconsulting.com
Fri Jan 30 07:58:19 CST 2004


Folks,

I am trying to clean up after my merge stuff.  If the user fails to close
the document, I have to do so before I can continue.  My mail stuff opens
two documents, which appear to be TWO instances of word.  Further the user
may already have a document of their own open.

It LOOKS like when several word documents are open, each one is an instance
of word.  There is an icon in the toolbar for each document.  I have the
following code (which works, kind of):

Public objWord As Word.Application

Function OpenWord() As Word.Application
    On Error Resume Next
    Set objWord = GetObject(, "Word.Application")
    If objWord Is Nothing Then
    Else
        objWord.Visible = True
    End If
End Function

Function TestWrdClose()
    OpenWord
    objWord.Quit False
    Set objWord = Nothing
End Function

The problem is, that if I have three docs open, when I call TestWrdClose ONE
TIME, all word docs close.  So....

I need to close any instances of word that I opened, yet leave any instances
that THEY opened.  I know (think) I can use code like

First question... Is it possible to open an instance of Word and give it a
"name" such that I can search for that "name", get a handle to that
instance, and then close it?.

Second question... I assume that in order to close it, all I need to do is
use the application.close once I have a handle?

Or is it just a simple matter of closing all my own documents, then seeing
if any documents are open, and if not closing the word instance?

John W. Colby
www.ColbyConsulting.com




More information about the AccessD mailing list