![]() |
Detect Outlook
Is it possible to detect if Outlook is running via VBA?
Pete |
Detect Outlook
Try code like the following:
Dim OutlookApp As Object On Error Resume Next Set OutlookApp = GetObject(, "Outlook.Application") On Error GoTo 0 If OutlookApp Is Nothing Then Debug.Print "Outlook not running" Else Debug.Print "Outlook running" End If -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Pete" wrote in message oups.com... Is it possible to detect if Outlook is running via VBA? Pete |
Detect Outlook
Dim oOutlook As Object On Error Resume Next Set oOutlook = GetObject(, "Outlook.Application") On Error GoTo 0 If Not oOutlook Is Nothing Then MsgBox "Outlook running" End If -- HTH Bob Phillips "Pete" wrote in message oups.com... Is it possible to detect if Outlook is running via VBA? Pete |
Detect Outlook
brilliant, thanks
|
Detect Outlook
(from Italy)
Great! But: 1. I check if Outlook is installed on my pc ============== Function ApplicationIsAvailable(ApplicationClassName As String) As Boolean 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 ============== 2. I check if Outlook is running ============== Function ApplicationIsRunning(ApplicationClassName As String) As Boolean 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 ============== 3. which is the VBA code in order to say to Excel: pls bring Outlook frontward With my poor skills I'0m using the command AppApplication that requires the name in the Application title bar and not the program name (in the specific it require "Inbox - Microsoft Outlook" and not "Outlook.exe"). ============== Private Sub myBtn_Click() If Not ApplicationIsAvailable("Outlook.Application") Then Exit Sub If ApplicationIsRunning("Outlook.application") = True Then AppActivate "Inbox - Microsoft Outlook" <==== ??????? Else Set myOlApp = CreateObject("Outlook.Application") Set myNameSpace = myOlApp.GetNamespace("MAPI") Set myFolder = myNameSpace.GetDefaultFolder(olFolderInbox) myFolder.Display End If End Sub ============== Thanks -- Sergiovery "Pete" wrote: brilliant, thanks |
All times are GMT +1. The time now is 05:58 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com