Question : Close Outlook via Access VBA

How can I close Outlook by using VBA code?  My RDC users are opening multiple instances of Outlook and that is causing problems/confusion.  I'd like to be able, upon opening a new Access form, to check to see if Outlook is open, and if it is, prevent another instance from opening.  If Outlook is not open, open it.

Best regards,
 
Rick Farris

[contact info deleted -- modus_operandi, EE Moderator]

Answer : Close Outlook via Access VBA

Hi, rhfarris.

You'll need something like the code below.  GetObject attempts to attach to an open Outlook session.  If there is one, then Err.Number will return 0.  If there isn't one, then Err.Number will return the error number which will be greater than 0.
1:
2:
3:
4:
5:
6:
7:
8:
9:
Dim olkApp
On Error Resume Next
Set olkApp = GetObject(,"Outlook.Application")
If Err.Number > 0 Then
    'Outlook is not open so open it
Else
    'Outlook is already open
End If
Set olkApp = Nothing
Open in New Window Select All
Random Solutions  
 
programming4us programming4us