Hello Test Screen Name. I do trap for the error and generate a friendly error message to ask the user to close Adobe Acrobat. The problem is, depending on the criteria they select for the report, it could take 5 to 10 minutes before they ever see that error message because of the hundreds of individual pdf reports it has to generate. It is not until my code is ready to combine those pdf files that they see the message. So, it is not really a runtime error so to speak.
But, I found the answer to my question and wanted to share it with everyone. The answers are located here:
API: Find out if an application is currently running
API: Get Class name of a running app
What I did is paste all code from those 2 pages into a new module in Access. Then I made sure that Adobe Acrobat is loaded on my machine. I ran the sub fEnumWindows() and it printed the Class Names of all of my open programs. I got the class name for Adobe Acrobat, which is AcrobatSDIWindow. Then I modified the select case statement in the following function as so, to include the string acrobat and its Class Name:
[code]
Function fIsAppRunning(ByVal strAppName As String, _
Optional fActivate As Boolean) As Boolean
Dim lngH As Long, strClassName As String
Dim lngX As Long, lngTmp As Long
Const WM_USER = 1024
On Local Error GoTo fIsAppRunning_Err
fIsAppRunning = False
Select Case LCase$(strAppName)
Case "excel": strClassName = "XLMain"
Case "word": strClassName = "OpusApp"
Case "access": strClassName = "OMain"
Case "powerpoint95": strClassName = "PP7FrameClass"
Case "powerpoint97": strClassName = "PP97FrameClass"
Case "notepad": strClassName = "NOTEPAD"
Case "acrobat": strClassName = "AcrobatSDIWindow"
Case "wordpad": strClassName = "WordPadClass"
Case Else: strClassName = vbNullString
End Select
If strClassName = "" Then
lngH = apiFindWindow(vbNullString, strAppName)
Else
lngH = apiFindWindow(strClassName, vbNullString)
End If
If lngH <> 0 Then
apiSendMessage lngH, WM_USER + 18, 0, 0
lngX = apiIsIconic(lngH)
If lngX <> 0 Then
lngTmp = apiShowWindow(lngH, SW_SHOWNORMAL)
End If
If fActivate Then
lngTmp = apiSetForegroundWindow(lngH)
End If
fIsAppRunning = True
End If
fIsAppRunning_Exit:
Exit Function
fIsAppRunning_Err:
fIsAppRunning = False
Resume fIsAppRunning_Exit
End Function
[/code]
Now I can just send "acrobat" to this function to see if the app is open.
Sincerely,
David