Jürgen Welz
jwelz at hotmail.com
Tue May 25 00:17:53 CDT 2004
Is it not as simple as using a call to GetObject?
Public Sub KillWord()
Dim objWord as Word.Application
Set objWord = GetObject(, "Word.Application")
If objWord Is Nothing Then
Else
objWord.Close
Set objWord = Nothing
End If
End Function
You may need to iterate the Word documents collection and close those first.
It could get ugly if the user has his own instance of Word open and you
start killing off his documents. I don't use conventional merges relying on
automation instead and have yet to have a problem with closing Word
instances. Your best bet so as not to get a user instance is to use
GetObject to secure pointers to all user instances before you begin your
merge and then kill instance where the object is not the same as one of the
user instances. For automation, it is usually enough to CreateObject and
check that it is nothing when you are done.
Ciao
Jürgen Welz
Edmonton, Alberta
jwelz at hotmail.com
>From: "John W. Colby" <jwcolby at colbyconsulting.com>
>
>I am doing mail merge and have times when instances of Word get "orphaned",
>i.e. are loaded but not visible on the task bar. This prevents the next
>merge cycle. I don't think that I am causing the orphans, they don't
>happen
>often but they are occurring. I don't know how to troubleshoot what is
>causing them, how they were opened etc.
>
>Is there any way to get a handle to these instances and close them
>programmatically?
>
>John W. Colby
>www.ColbyConsulting.com
_________________________________________________________________
MSN Premium with Virus Guard and Firewall* from McAfee® Security : 2 months
FREE*
http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines