> It looks like a relatively standard implementation of the ItemsCB VB6
> template.
>
> Don't do anything in NewInspector other than instantiating your Inspector
> class or event handler. Never call Inspector.Activate in that event. Wait
> for the first Inspector.Activate event to fire before adding your UI and
> doing anything else with that Inspector. In NewInspector you're given what's
> known as a "weak" object reference, where not all properties of the
> Inspector or Inspector.CurrentItem are populated. In NewInspector you really
> shouldn't be doing much else than checking for Inspector.CurrentItem.Class
> or Inspector.CurrentItem.MessageClass and then instantiating your Inspector
> handler or wrapper class.
>
> --
> 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>
> <for...[ at ]webgremlins.net> wrote in message
>
> news:1172585059.710141.158000[ at ]k78g2000cwa.googlegroups.com...
> <snip>
>
>
>
> > Hi Ken
>
> > Thankyou for the reply. I have gone trhough and stripped my code down.
> > I do hope it is a simple error!
>
> > I have this class calld OutAddIn
>
> > Option Explicit
> > 'Object variables for Event procedures
> > Private WithEvents objOutlook As Outlook.Application
> > Private WithEvents objWord As Word.Application
> > Private WithEvents objNS As Outlook.NameSpace
> > Private WithEvents objExpl As Outlook.Explorer
> > Private WithEvents colExpl As Outlook.Explorers
> > Private WithEvents objInsp As Outlook.Inspector
> > Private WithEvents colInsp As Outlook.Inspectors
> > Private WithEvents objMailItem As Outlook.MailItem
> > Private WithEvents objPostItem As Outlook.PostItem
> > Private WithEvents objContactItem As Outlook.ContactItem
> > Private WithEvents objDistListItem As Outlook.DistListItem
> > Private WithEvents objApptItem As Outlook.AppointmentItem
> > Private WithEvents objTaskItem As Outlook.TaskItem
> > Private WithEvents objJournalItem As Outlook.JournalItem
> > Private WithEvents objDocumentItem As Outlook.DocumentItem
>
> > '******************************************************************************
> > 'These event-aware objects are for Outlook 2002 only
> > 'Uncomment to use in Outlook 2002 COM Add-in
> > 'Private WithEvents colViews As Outlook.Views
> > 'Private WithEvents objResults As Outlook.Results
> > 'Private WithEvents colReminders As Outlook.Reminders
> > '******************************************************************************
> > 'Declare CommandBar, CommandBarButton, and CommandBarComboBox object
> > variables here
> > 'Don't use WithEvents for CommandBar object
> > 'Remove comments to declare object variables for CommandBar objects
> > 'Dim objCB As Office.CommandBar
> > 'Dim WithEvents objCBButton As Office.CommandBarButton
> > 'Dim WithEvents objCBComboBox As Office.CommandBarComboBox
> > oSendLogMenuBar
> > Dim objCBars As Office.CommandBars
> > Dim objCB As Office.CommandBar
> > Dim oMyControl As Office.CommandBarPopup
> > Dim bar As Office.CommandBar
>
> > Dim WithEvents oSealandSendMenuBar As Office.CommandBarButton
> > Dim WithEvents oVerifyMenuBar As Office.CommandBarButton
> > Dim WithEvents oVerifyExternalMenuBar As Office.CommandBarButton
> > Dim WithEvents oExtractMenuBar As Office.CommandBarButton
> > Dim WithEvents oAboutMenuBar As Office.CommandBarButton
> > Dim WithEvents oHelpMenuBar As Office.CommandBarButton
> > Dim WithEvents oSendLogMenuBar As Office.CommandBarButton
> > Dim WithEvents oWordSealandSendMenuBar As Office.CommandBarButton
>
> > Dim WithEvents oSealandSendToolBar As Office.CommandBarButton
> > Dim WithEvents oVerifyToolBar As Office.CommandBarButton
> > Dim WithEvents oExtractToolBar As Office.CommandBarButton
> > 'Dim WithEvents oTitleToolBar As Office.CommandBarButton
> > 'Dim WithEvents oValidateExternalToolBar As Office.CommandBarButton
>
> > 'controls for new inspector objects
> > Dim WithEvents oSealandSendNew As Office.CommandBarButton
> > Dim WithEvents oSealAttachmentNew As Office.CommandBarButton
> > Dim WithEvents oSealAllAttachmentsNew As Office.CommandBarButton
> > Dim WithEvents oVerifyNew As Office.CommandBarButton
> > Dim WithEvents oExtractNew As Office.CommandBarButton
>
> > Dim ShowSealAndSendControl As Boolean
> > Dim OutlookVersion As String
>
> > Private Declare Function ShellExecute Lib "shell32.dll" Alias
> > "ShellExecuteA" _
> > (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As
> > String, _
> > ByVal lpParameters As String, ByVal lpDirectory As String, ByVal
> > nShowCmd As Long) As Long
>
> > '******************************************************************************
>
> > '******************************************************************************
> > 'Custom procedure: InitHandler(olApp As Outlook.Application, strProgID
> > As String)
> > 'Purpose: Initialize event-aware object variables
> > '******************************************************************************
> > Friend Sub InitHandler(olApp As Outlook.Application, strProgID As
> > String)
>
> > 'On Error Resume Next
>
> > Set objOutlook = olApp 'Application Object
>
> > 'Instantiate a public module-level Outlook application variable
> > Set m_olApp = olApp
> > 'CDO Session if required
> > 'Uncomment for CDO
> > 'Set m_objCDO = CreateObject("MAPI.Session")
> > 'm_objCDO.Logon "", "", False, False
> > 'Declared WithEvents
> > Set objNS = objOutlook.GetNamespace("MAPI") 'NameSpace Object
> > 'Uncomment to use in Outlook 2002 COM Add-in
> > 'Set colReminders = objOutlook.Reminders 'Reminders Object
> > Set colExpl = objOutlook.Explorers 'Explorers Object
> > Set colInsp = objOutlook.Inspectors 'Inspectors Object
> > Set objExpl = objOutlook.ActiveExplorer 'Explorer Object
>
> > End Sub
>
> > 'detect the type, then bind the new inspector item to ObjMailitem
> > Private Sub colInsp_NewInspector(ByVal Inspector As Inspector)
>
> > Dim objItem As Outlook.MailItem
>
> > Set objInsp = Inspector
> > objInsp.Activate
> > Set objItem = objInsp.CurrentItem
> > Select Case objItem.Class
> > Case olMail
> > Set objMailItem = objItem
> > End Select
>
> > Set objItem = Nothing
> > End Sub
>
> > Private Sub objMailItem_Open(Cancel As Boolean)
> > Call addControls
> > End Sub
>
> > Private Sub addControls()
>
> > Dim cmdBar As Office.CommandBar
> > Dim cmdBars As Office.CommandBars
> > Set cmdBars = objMailItem.GetInspector.CommandBars
>
> > On Error Resume Next
> > Dim deletebar As Office.CommandBar
> > Set deletebar = cmdBars.Item("bar")
> > deletebar.Delete
> > deletebar = Nothing
> > On Error GoTo 0
>
> > Set cmdBar = cmdBars.Add("bar", 1, False, True)
>
> > Set oSealAllAttachmentsNew =
> > cmdBar.Controls.Add(Type:=msoControlButton, Temporary:=True)
> > oSealAllAttachmentsNew.Caption = "TruSeal &All Attachments"
> > oSealAllAttachmentsNew.ToolTipText = "Click here to Seal the
> > attachments on this email"
> > oSealAllAttachmentsNew.Tag = "oSealAllAttachmentsNew"
> > oSealAllAttachmentsNew.Style = msoButtonCaption
> > oSealAllAttachmentsNew.Visible = True
>
> > cmdBar.Visible = True
>
> > End Sub
>
> > 'when i detect here the to value, it doesnt show anything.
> > Private Sub oSealAllAttachmentsNew_click(ByVal Ctrl As
> > Office.CommandBarButton, CancelDefault As Boolean)
> > MsgBox objInsp.CurrentItem.To
> > End Sub
>
> > This is my designers connect class
>
> > Option Explicit
> > 'Use Implements IDTExtensibility2 in VB5 environment
> > 'Implements IDTExtensibility2
> > Private gBaseClass As New OutAddIn
>
> > Private Sub AddinInstance_OnAddInsUpdate(custom() As Variant)
> > 'DebugWrite "AddinInstance_OnAddInsUpdate"
> > End Sub
>
> > Private Sub AddinInstance_OnBeginShutdown(custom() As Variant)
> > 'DebugWrite "AddinInstance_OnBeginShutdown"
> > End Sub
>
> > Private Sub AddinInstance_OnConnection(ByVal Application As Object, _
> > ByVal ConnectMode As AddInDesignerObjects.ext_ConnectMode, _
> > ByVal AddInInst As Object, custom() As Variant)
>
> > 'On Error Resume Next
> > 'Evaluate ConnectMode
> > Select Case ConnectMode
> > Case ext_cm_Startup
> > Case ext_cm_AfterStartup
> > Case ext_cm_CommandLine
> > Case ext_cm_Startup
> > End Select
> > 'Don't call InitHandler if Explorers.Count = 0 and
> > Inspectors.Count = 0
> > If Application.Explorers.count = 0 And
> > Application.Inspectors.count = 0 Then
> > Exit Sub
> > End If
>
> > 'AddInInst represents COMAddIn object
> > 'Create and Initialize a base class
> > gBaseClass.InitHandler Application, AddInInst.ProgId
> > 'DebugWrite "IDT2 OnConnection"
>
> > End Sub
>
> > Private Sub AddinInstance_OnDisconnection(ByVal RemoveMode _
> > As AddInDesignerObjects.ext_DisconnectMode, custom() As Variant)
> > 'Tear down the class
> > 'IMPORTANT: This event will not fire when
> > 'RemoveMode = ext_dm_HostShutdown
> > 'It will fire when RemoveMode = ext_dm_UserClosed
>
> > 'gBaseClass.UnInitHandler
> > If RemoveMode = ext_dm_UserClosed Then
> > 'User shutdown removed COM Add-in
> > 'Cleanup custom toolbars by deleting them
> > Else
> > 'Host shutdown
> > End If
> > Set gBaseClass = Nothing
> > If Constants.DEBUG_MODE = True Then
> > DEBUG_FILE.Write "AddinInstance_OnDisconnection: completed" &
> > " " & Time & vbCrLf
> > End If
> > 'DebugWrite "AddinInstance_OnDisconnection"
> > End Sub
>
> > Private Sub AddinInstance_OnStartupComplete(custom() As Variant)
> > '
> > 'DebugWrite "AddinInstance OnStartupComplete"
> > End Sub- Hide quoted text -
>
> - Show quoted text -