This will close all open instances.
'Set reference to Microsoft Word x.0 Library
Sub CloseWord()
Dim WordApp As Word.Application
Const ERR_APP_NOTRUNNING As Long = 429
On Error Resume Next
Set WordApp = GetObject(, "Word.Application")
' If no instances running, exit sub.
If Err = ERR_APP_NOTRUNNING Then
Exit Sub
Else
WordApp.Quit
Set WordApp = Nothing
End If
End Sub
HTH,
Bob
|