Outlook 2010 Active Inspector

Add-in Express™ Support Service
That's what is more important than anything else

Outlook 2010 Active Inspector
Outlook 2010 behaves differently to previous versions 
Garry Lowther

Posts: 54
Joined: 2009-02-22
I have a function which is called when the user clicks either a toolbar button in Outlook 2007 or earlier, and also from a ribbon button in Outlook 2007 or 2010. This function returns True if the button click is from a button on the main explorer view:

Public Function isExplorerView() As Boolean
        Dim sDebug As String = "isExplorerView" & vbCrLf
        Dim bExplorerView As Boolean = True

            Dim olInspector As Outlook.Inspector = TryCast(m_OutlookApplication.ActiveInspector(), Outlook.Inspector)
            If olInspector IsNot Nothing Then
                If TypeOf olInspector.CurrentItem Is Outlook.MailItem Then
                    bExplorerView = False
                End If
            End If

            ' Else must be true?

        Catch ex As Exception

        End Try

        sDebug &= vbCrLf & "bExplorerView=" & bExplorerView


        Return bExplorerView
    End Function

The problem is that this technique breaks down i.e. does not work for Outlook 2010 when clicked from the main explorer ribbon.

What is the best way to address this?
Posted 27 Apr, 2011 03:40:43 Top
Eugene Astafiev


Hi Garry,

The approach you currently use for detecting the active window where the button was clicked is not right. Instead, please use the Context property of the control parameter passed to the button Click event handler:

Outlook.Explorer explorer = control.Context as Outlook.Explorer;
if (explorer != null) System.Windows.Forms.MessageBox.Show("explorer");
Outlook.Inspector inspector = control.Context as Outlook.Inspector;
if (inspector != null) System.Windows.Forms.MessageBox.Show("inspector");

Please separate command bar and ribbon controls in your add-in project. Note, you can use the UseForRibbon property of your command bar.
Posted 27 Apr, 2011 07:42:38 Top