I usually just check for applicationObject.Explorers.Count in OnConnection
and if 0 I add the Explorer to a sorted List collection. I do that with an
Explorer wrapper class that is the event handler for events fired in that
Explorer (Activate, Close, SelectionChange, maybe some item events). I add
the Explorer instance there also and create my UI in the class when either
Activate, SelectionChange or BeforeFolderSwitch fires).
Something like this:
Public Sub OnConnection(ByVal application As Object, ByVal connectMode
As Extensibility.ext_ConnectMode, ByVal addInInst As Object, ByRef custom As
System.Array) Implements Extensibility.IDTExtensibility2.OnConnection
m_blnTeardown = False
addInInstance = Nothing
addInInstance = TryCast(addInInst, Office.COMAddIn)
If (addInInstance IsNot Nothing) Then
'set module level reference to COMAddIn object
Try
m_objOutlook = CType(application, Outlook.Application)
'event-aware reference to Explorers collection
'use NewExplorer event to watch for UI creation
m_colExplorers = m_objOutlook.Explorers
Try
'put ProgID in a global variable
g_strProgID = addInInstance.ProgId
addInInstance.Object = Me
'Are we starting with UI?
If m_colExplorers.Count 0 Then
'we have UI
InitHandler()
If m_blnInit = True Then
AddExpl(m_olExplorer) 'add to wrapper class
collection
End If
m_objNS = m_objOutlook.GetNamespace("MAPI")
m_colInspectors = m_objOutlook.Inspectors
Else
'do nothing
'monitor Explorers collection (in this module)
'if NewExplorer event is raised then we have UI
End If
Catch ex As Exception
TearDown()
End Try
Catch ex As Exception
TearDown()
End Try
Else
TearDown()
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
wrote in message
ups.com...
I'm also unable to get the objCommandBars.Count or see what's actually
inside it. It only seems to like when I feed it the ActiveExplorer.
-Steve