Author: Calvin Smith
http://www.CalvinSmithSoftware.com/codedisk/sneakpeek.htm

The following code will allow a developer to programmatically
determine if MS Word is loaded.


NOTE: This function, plus some of my others, were featured in
The Visual Basic Programmer's Journal Top 101 Tech Tips Issue.


'We need the following API declarations first...

Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( _
      ByVal lpClassName As Any, _
      ByVal lpWindowName As Any) As Long

Function IsMicrosoftWordRunning_API() As Boolean

On Error GoTo ErrorHandling_Err

' ---------------------------------------------------------------------------------
' Author: Calvin Smith - JobForCalvin@Yahoo.com
' Environment(s): MS Access (32-bit) / Visual Basic (32-bit)
' ---------------------------------------------------------------------------------
'
'   *****************************************
'   * Courtesy code from my CodeDisk© product
'   *****************************************
   '
   ' ----------------------------------------------------------------------------
   ' Purpose: Determine if MS Word is open via an API
   '
   ' Accepts: Nothing
   '
   ' Returns: True if Word is loaded, False otherwise
   '
   ' Example: bRetVal = IsMicrosoftWordRunning_API()
   ' ----------------------------------------------------------------------------
   '

          IsMicrosoftWordRunning_API = (FindWindow("OpusApp", vbNullString) <> 0)

ErrorHandling_Exit:
   Exit Function

ErrorHandling_Err:

   If Err Then
       MsgBox Err.Description
       Resume ErrorHandling_Exit
   End If

End Function