[AccessD] Is MSWord.exe running??

Hale, Jim jim.hale at fleetpride.com
Thu Jun 12 17:57:33 CDT 2003


I modified this from code i use to close excel. It  works but the line to
save the word doc needs the correct syntax. HTH
Jim Hale

Function Word_is_running() As Boolean
Dim appWord As Word.Application
On Error Resume Next
Set appWord = GetObject(, "Word.Application")
Word_is_running = (Err.Number = 0)
Set appWord = Nothing
Err.Clear
End Function
Function CloseWord() As Boolean
If Word_is_running = True Then
    Dim lngRetval As Long
Dim appWord As Word.Application
    lngRetval = MsgBox( _
        "Can Word be closed so I can proceed? All changes will be saved.", _
        vbYesNo + vbExclamation + vbSystemModal + vbDefaultButton1, _
        "Close Word")

    Select Case lngRetval
        Case vbYes
            
            On Error Resume Next
            Set appWord = GetObject(, "Word.Application")
            xlsClose appWord
            CloseWord = True
        Case vbNo
            CloseWord = False
   End Select
Else
CloseWord = True
End If
End Function

Sub xlsClose(appWord As Word.Application)
On Error Resume Next
appWord.DisplayAlerts = False
'this syntax needs to be fixed:
'appWord.Close SaveChanges:=True
appWord.Quit
Set appWord = Nothing
Exit_xlsClose:
Exit Sub
End Sub


Sub test()
CloseWord
End Sub

-----Original Message-----
From: Selina Iddon [mailto:selina at easydatabases.com.au]
Sent: Thursday, June 12, 2003 5:20 PM
To: accessd at databaseadvisors.com
Subject: [AccessD] Is MSWord.exe running??


Good Morning Everyone

I have an application that silently opens MS Word, merges it, saves it  etc,
without the user sitting watching the whole flickering effect.  Problem is
if it errors, the Process is left running in the Task Manager, and the
novice user has to restart the PC or go into Task Manager and End Task the
process. (Otherwise it causes errors next time).

Can anyone please help me with code to 1.  check if a MS Word process is
running and 2. end it.

Thanks Heaps
Selina


_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://databaseadvisors.com/pipermail/accessd/attachments/20030612/568a5a23/attachment-0001.html>


More information about the AccessD mailing list