Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Detect Outlook

Is it possible to detect if Outlook is running via VBA?

Pete

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,120
Default 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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Detect Outlook

brilliant, thanks

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default 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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
custimized outlook today in outlook 2007 Hal Excel Discussion (Misc queries) 2 June 20th 07 12:59 AM
Outlook 11 Outlook 10 Object Library Compatibility Issues Paul Mac[_4_] Excel Programming 11 May 19th 06 04:27 AM
Detect Outlook is running Pete[_4_] Excel Programming 2 May 13th 05 05:30 PM
Late Binding to Outlook from Excel: Outlook modifies email body Lenny Wintfeld Excel Programming 0 December 12th 04 04:03 PM
Display mail application either in Outlook, or Outlook express [email protected] Excel Programming 0 April 13th 04 09:50 PM


All times are GMT +1. The time now is 12:32 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"