I have a function in an access form that checks if various office apps are already running:
Function IsAppRunning(appName As OfficeAppName) As Boolean
On Error GoTo NotRunning
Dim officeApp As Object
Dim appString As String
' assume true
IsAppRunning = True
' determine which app is being checked
Select Case appName
Case 1 ' Outlook
appString = "Outlook"
Case 2 ' PowerPoint
appString = "PowerPoint"
Case 3 ' Excel
appString = "Excel"
Case 4 ' Word
appString = "Word"
Case 5 ' Publisher
appString = "Publisher"
Case 6 ' Access
appString = "Access"
End Select
' try to hook into existing object
Set officeApp = GetObject(, appString & ".Application")
ExitProc:
Exit Function
NotRunning:
IsAppRunning = False
Resume ExitProc
End Function
Recently it is causing my form to freeze on some occasions. It works for a while and then starts acting up. I have to use task manager to quit access. Restart PC and it all good for a while until it freezes again. I have been using this code for a few years without issue.
Does anyone know what could be going wrong?