How to find out if Outlook is Active

  • Thread starter Thread starter Xcelsoft
  • Start date Start date
X

Xcelsoft

Is there some VB code to test from within Access to see
if Outlook is loaded??

I want to test first before sending emails from Access.

Thanks,

Xcelsoft
 
Dim oOL As Outlook.Application
On Error Resume Next
Set oOL = GetObject(, "Outlook.Application")
If oOL Is Nothing Then
'not running already, start it
Set oOL = CreateObject("Outlook.Application")
Else
'is running
End If
 
Ken

Question for clarification. do you have to test if outlook is running
If you just use the CreateObject, doesn't just focus on outlook an
not create another instance

Cheers

Joh

----- Ken Slovak - [MVP - Outlook] wrote: ----

Dim oOL As Outlook.Applicatio
On Error Resume Nex
Set oOL = GetObject(, "Outlook.Application"
If oOL Is Nothing The
'not running already, start i
Set oOL = CreateObject("Outlook.Application"
Els
'is runnin
End I

--
Ken Slova
[MVP - Outlook
http://www.slovaktech.co
Author: Absolute Beginner's Guide to Microsoft Office Outlook 200
Reminder Manager, Extended Reminders, Attachment Option
http://www.slovaktech.com/products.ht
 
Yes, if you use CreateObject and an instance of Outlook is already running
then that will return a handle to the running instance of Outlook.

The reason for doing that test is to see if your own code actually started
Outlook. If it did you might want to shut it down when your code completes.
If the user had already started Outlook themselves and you shut it down it
tends to tick them off...
 
Back
Top