VBA - From MS Access How to determine if MS Word is running.
Posted on 2011-10-09
Using MS Access 2003. I open a Word document, but need to know how to determine if MS Word is closed before closing a MS Access form. The Word application object is 'wo'. I get the run-time error as mentioned below.
Private Sub cmdbCloseCC_Click()
On Error GoTo PROC_ERR
Dim wn As String
wn = "Word.Application"
If Me.IsAppRunning(wn) = True Then
Set wo = Nothing
DoCmd.Close acForm, "frmCC_Status"
Function IsAppRunning(ByVal appName) As Boolean
Dim oApp As Object
On Error Resume Next
Set oApp = GetObject(, appName) 'Error here - Run-time error '429': ActiveX component can't create object
If Not oApp Is Nothing Then
Set oApp = Nothing
IsAppRunning = True