Hi Guys. I have this module that works great. all it does is tell me if whatever Microsoft office program is open. The problem i get is that when i add the reference Microsoft outlook 14.0 object library i get a compile error "ByRef argument type mismatch" How can i fix this? I call the function to verify outlook is open before an automatic email is sent. Even when i try to use ?IsAppRunning(outlook) in the immediate window it gives me that error unless i remove the reference. Thanks!
Code:
Option Compare Database
Public Enum OfficeAppName
Outlook = 1
powerpoint = 2
excel = 3
Word = 4
Publisher = 5
Access = 6
End Enum
Function IsAppRunning(appName As OfficeAppName) As Boolean
On Error GoTo NotRunning
Dim officeApp As Object
Dim appString As String
IsAppRunning = True
Select Case appName
Case 1
appString = "Outlook"
Case 2
appString = "PowerPoint"
Case 3
appString = "Excel"
Case 4
appString = "Word"
Case 5
appString = "Publisher"
Case 6
appString = "Access"
End Select
Set officeApp = GetObject(, appString & ".Application")
ExitProc:
Exit Function