I am looking for a way to check if MS Access is installed and then if it is not Exit Sub or finish running the rest of the module. I came across this bit of code, but I am unsure of how to adapt it to suit my needs.
Function ApplicationIsAvailable(ApplicationClassName As String) As Boolean
' returns True if the application is available
' example: If Not ApplicationIsAvailable("Outlook.Application") Then Exit Sub
Dim AnyApp As Object
On Error Resume Next
Set AnyApp = CreateObject(ApplicationClassName)
ApplicationIsAvailable = Not AnyApp Is Nothing
Set AnyApp = Nothing
On Error GoTo 0
End Function
Thank you in advance if anyone is able to assist.
I ended up getting this to work not long after I posted the question. In case anyone was curious, I used the above code to declare the function and then within my module that I was running I used this bit of code to determine if it was available.
If ApplicationIsAvailable("Access.Application") = False Then
MsgBox ("You must have Microsoft Access installed to use this function")
Exit Sub
End If
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.