Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Is it possible to detect if Outlook is running via VBA?
Pete |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
brilliant, thanks
|
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
(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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
custimized outlook today in outlook 2007 | Excel Discussion (Misc queries) | |||
Outlook 11 Outlook 10 Object Library Compatibility Issues | Excel Programming | |||
Detect Outlook is running | Excel Programming | |||
Late Binding to Outlook from Excel: Outlook modifies email body | Excel Programming | |||
Display mail application either in Outlook, or Outlook express | Excel Programming |