Is MS Word running

  • Thread starter Thread starter Enzo Diana
  • Start date Start date
E

Enzo Diana

Hi
A function of an Access 2K application I am building is to create files
names from various data, and using the shell command pass the filename to
(and open) MS Word, thereby opening the respective document.
This works great but there is a problem if word is already open.
Is there a way to test if MS Word is running and if so shut it down.

Thanks in anticipation
 
Global ObjWd As Object

Sub UseWord()
On Error Resume Next
Set ObjWd = GetObject(, "Word.Application")
If Not TypeName(ObjWd) = "Nothing" Then
' ' Word Running
Else
' Word Not Running
NotRunning:
Set ObjWd = CreateObject("Word.Application")
End If
ObjWd.Visible = True
ObjWd.Activate
On Error GoTo 0
Set myDoc = ObjWd.Documents.Add 'etc, etc
End Sub
 
Back
Top