have access close Outlook

  • Thread starter Thread starter Southern at Heart
  • Start date Start date
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.
 
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
 
Back
Top