我正在寻找一种方法,以检查是否安装了MS Access,然后如果它不是退出Sub或完成运行模块的其余部分。我偶然发现了这段代码,但我不知道如何使它适应我的需要。
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如果有人能帮忙的话,请提前感谢。
发布于 2015-10-10 08:45:28
在我贴出这个问题后不久,我就让这个问题起作用了。如果有人好奇,我使用上面的代码来声明函数,然后在我运行的模块中使用这段代码来确定它是否可用。
If ApplicationIsAvailable("Access.Application") = False Then
MsgBox ("You must have Microsoft Access installed to use this function")
Exit Sub
End Ifhttps://stackoverflow.com/questions/33051739
复制相似问题