» Determine if an application is available using VBA in Microsoft Excel
VBA macro tip contributed by Erlandsen Data Consulting offering Microsoft Excel Application development, template customization, support and training solutions
CATEGORY - Applications - Word, Outlook in VBA
VERSION - All Microsoft Excel Versions
You can use the two functions below to determine if an application is already running or if it is available on the host computer:
Function ApplicationIsRunning(ApplicationClassName As String) As Boolean
' returns True if the application is running
' example: If Not ApplicationIsRunning("Outlook.Application") Then Exit Sub
Dim AnyApp As Object
On Error Resume Next
Set AnyApp = GetObject(, ApplicationClassName)
ApplicationIsRunning = Not AnyApp Is Nothing
Set AnyApp = Nothing
On Error GoTo 0
End Function
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
Book Store:
Recommended Books:
- Accounting Principles, with CD, 6th Edition
- Windows XP All-in-One Desk Reference For Dummies
- Treason: Liberal Treachery from the Cold War to the War on Terrorism
- Millionaire Real Estate Mentor : The Secrets of Financial Freedom through Real Estate Investing
- Keys to Reading an Annual Report (Barron's Business Keys)
- How to Pay Zero Taxes (Annual)
No comments have been submitted.

