have access close Outlook

S

Southern at Heart

Can I have my Access VBA code close Outlook? I have Outlook 2003, but it'd
be nice if it worked for 2007, too...
If Outlook is open, then when I use the outlook pickfolder routine, it
leaves the focus on Outlook, and the user doesn't see the Access User form
anymore! This is too bad, I wish there were a way to just bring the focus
back to Access, but I've asked this question in several different newsgroups
and no one has any answer. If Outlook is closed, then the focus doens't
leave Access and jump to Outlook...
thanks.
 
B

BeWyched

Try:

Set objOutlook = GetObject(, "Outlook.Application")
objOutlook.Quit

best to surround it in a loop in case there is more than 1 instance of
Outlook open, with error capture to release the loop when all instances are
closed:

On Error GoTo OutlookIsClosed
OutlookIsOpenPerhaps:
Set objOutlook = GetObject(, "Outlook.Application")
objOutlook.Quit
GoTo OutlookIsOpenPerhaps
OutlookIsClosed:

BW
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top