Link to home
Start Free TrialLog in
Avatar of Greekiwi
Greekiwi

asked on

Opening Outlook from Access, if not already open

I have a code that opens MS Outlook from Access. However if I click it, and Outlook is already open, it opens another copy of it.

What I want is, if Outlook is already open, it just brings it to focus, not opens another copy.
MyAppID = Shell("C:\Program Files (x86)\Microsoft Office\Office12\Outlook.exe", 1)

Open in new window

Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image



Dim oOutlook As Object
    Dim oNameSpace As Object
    Dim oInbox As Object
     
    Set oOutlook = CreateObject("Outlook.Application")
    Set oNameSpace = oOutlook.GetNamespace("MAPI")
    Set oInbox = oNameSpace.Folders(1)
     
    oOutlook.Quit 'Close All Outlook copies if open

    Set oInbox = oInbox.Folders("Inbox")
    oInbox.Display
Avatar of Greekiwi
Greekiwi

ASKER

Hi Capricorn,

This closes all other windows of Outlook, but doesn't open a new one. When I click it a second time it opens (not fully maximised) with Inbox open.

I have Outlook set to open with calendar, so if I could retain that, it would be nice.

Cheers
SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
It opens one when nothing is open, but when one is open I get this message:

"Cannot set the WindowState of this Explorer or Inspector since it has not yet been made visible."
You might read over this. It includes code samples that show how to check to see if your CreateObject call suceeds or fails:

http://msdn.microsoft.com/en-us/library/aa164798(office.10).aspx
i tested those codes i posted and it works without any problem.
Are you running Vista / Office 07? As I still get the error I posted earlier.
That could be the problem. Have you ever encountered that problem before with any other things?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial