Group:  Microsoft Outlook ยป microsoft.public.outlook.program_addins
Thread: Outlook.Application handles Quit

Geek News

Outlook.Application handles Quit
"donald" <jonathan[ at ]dorling.biz> 2/13/2006 2:26:17 PM
Hi there,

I got this code below from my COM add-in which handles the Quit on my
outlook Application but it never get fired why is this? and how can i
fix this?

Thankls

Donald

Public WithEvents _Application As Outlook.Application

Private Sub app_quit() Handles _Application.Quit
MsgBox(_Application.Inspectors.Count)
MsgBox(_Application.Explorers.Count)
End Sub

Re: Outlook.Application handles Quit
"Ken Slovak - [MVP - Outlook]" <kenslovak[ at ]mvps.org> 2/14/2006 7:24:20 PM
By the time Quit fires all of you Outlook objects are out of scope so the
event won't fire correctly. It will fire in the Outlook VBA, but again all
objects are out of scope so it's a pretty useless procedure for that.

Use Explorer.Close and Inspector.Close to check the counts of both
collections.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"donald" <jonathan[ at ]dorling.biz> wrote in message
news:1139840777.493572.120350[ at ]g14g2000cwa.googlegroups.com...
[Quoted Text]
> Hi there,
>
> I got this code below from my COM add-in which handles the Quit on my
> outlook Application but it never get fired why is this? and how can i
> fix this?
>
> Thankls
>
> Donald
>
> Public WithEvents _Application As Outlook.Application
>
> Private Sub app_quit() Handles _Application.Quit
> MsgBox(_Application.Inspectors.Count)
> MsgBox(_Application.Explorers.Count)
> End Sub
>

Re: Outlook.Application handles Quit
"donald" <jonathan[ at ]dorling.biz> 2/15/2006 4:17:08 PM
Hi Ken,

Thanks for your reply.

I basic don't know outlook to close and my COM add-in to close if there
are any Inspector Open?

How would i do about doing this?

Thanks

Donald

Re: Outlook.Application handles Quit
"Ken Slovak - [MVP - Outlook]" <kenslovak[ at ]mvps.org> 2/16/2006 2:45:54 PM
Outlook won't close if there are any open Inspectors or Explorers. That
would keep it open.

You must check for any existing Explorers and Inspectors when an
Inspector.Close or Explorer.Close event fires, something like this:

Private Sub objExpl_Close()
On Error Resume Next

'Current Explorer is closing--update identity to ActiveExplorer
Set objExpl = objOutlook.ActiveExplorer

'if this is the last Explorer, then objExpl = Nothing ->close down
If (objExpl Is Nothing) And (objOutlook.Inspectors.Count = 0) Then
UnInitHandler
End If
End Sub

Private Sub objInsp_Close()
On Error Resume Next

Set objInsp = objOutlook.ActiveInspector

If objOutlook.Explorers.Count = 0 And objOutlook.Inspectors.Count <= 1
Then
UnInitHandler
End If
End Sub

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"donald" <jonathan[ at ]dorling.biz> wrote in message
news:1140020228.320900.62450[ at ]g14g2000cwa.googlegroups.com...
[Quoted Text]
> Hi Ken,
>
> Thanks for your reply.
>
> I basic don't know outlook to close and my COM add-in to close if there
> are any Inspector Open?
>
> How would i do about doing this?
>
> Thanks
>
> Donald
>

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net