> In order for On_Disconnection to fire when Outlook is closed all Outlook
> objects must be released first. So you will need to handle the
> Inspector.Close and Explorer.Close events for their respective collections
> and check for conditions like the following:
>
> 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
>
> 'Call UnInitHandler in objInsp_Close event
> 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
>
> Of course you would have to maintain a collection of Explorers and
> Inspectors in a wrapper collection to keep all the references alive as
> needed and to instantiate members of those collections as Inspectors and
> Explorers are opened.
>
> See the ItemsCB VB 6 COM addin template on the Resources page at
> www.microeye.com for an example of a lot of this plus an Explorer wrapper
> plus workarounds for other common Outlook addin bugs.
>
> --
> 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>
>
> "Jeff Simcock" <jeff[ at ]work> wrote in message
> news:uSpKSkwJGHA.604[ at ]TK2MSFTNGP14.phx.gbl...
>> hi gurus
>>
>> Apologies for cross posting to the above 2 newsgroups...but wasnt sure
>> which was the best for this post.
>>
>> I have an Outlook Office AddIn which creates some Toolbar and menu items
>> to access it. It connects to SQL Server when activated and all works
>> fine.
>>
>> If I open Outlook but dont access the addin and then close Outlook,
>> Outlook does its normal ~5 second delay in the Task List before
>> closing...all is well.
>>
>> If I open Outlook and access my addin logon form by just pressing the
>> toolbar item and not actually logging onto SQL Server, and then close my
>> addin form and then close Outlook, Outlook remains in the Task List
>> forever. In some cases (OS/OFFICE combinations) it even causes a crash.
>> The DLL has been built under VB6, Win2000 and Office 2000 as my clinets
>> have various platforms and so the LCN was chosen for compatability.
>>
>> All the functions of the ADDIN work fine and do what they are meant to
>> do. This behaviour has only recently started occuring AFTER I added some
>> fields to one form, the relevant SQL statements and then rebuilt it and
>> distributed it.
>>
>> When I run my VB App in debug mode in VB6 and follow the same process and
>> access the Addin and then close it and Outlook all works well. After the
>> ~5 seconds the VB Addin IDTExtensibility2_OnBeginShutdown is triggered
>> and all appears to work well. Its just when I build the DLL and then run
>> Outlook that it all fails.
>>
>> Any advice gratefully welcomed. If I have not given enough information
>> please interrogate me!!
>>
>> cheers
>> jeff
>>
>