none
ActiveInspector is Nothing in Outlook 2016 getVisible-Callback function RRS feed

  • Question

  • Hello all,

    i have an Outlook Com Add-In written in VB.NET working together with Outlook since Outlook 2010.

    Since one of the latest Outlook 2016 updates a call to ActiveInspector gives nothing when called from the getVisible-Callback function when double clicking an email in Outlook.

    The ribbon.XML is like:

    <customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" onLoad="Ribbon_Load">
      <ribbon startFromScratch="false">
        <tabs>
          <tab id="MyTab" label="MyProgram" getVisible="RibbonTabGetVisibility">
            <group id="MYGroup" label="MyProgram">
    ...
    
            </group>
          </tab>
        </tabs>
      </ribbon>
    </customUI>  

    The Callback-Function RibbonTagGetVisibility:
    Public Function RibbonTabGetVisibility(ByVal control As IRibbonControl) As Boolean
                If TypeOf (Me._applicationObject) Is Microsoft.Office.Interop.Outlook.Application Then
                    If myOlApp Is Nothing Then _
                        myOlApp = CType(Me._applicationObject, Microsoft.Office.Interop.Outlook.Application)
    
                    If myAInspector Is Nothing Then _
                        myAInspector = myOlApp.ActiveInspector()
    
    
    

    myOlApp is not nothing! This code still works in Outlook 2013 and Outlook 2010. Is it a bug or is it working as expected?

    Thanks for any reply in advance!

    KR, Pascal

    Tuesday, February 26, 2019 4:40 PM

Answers

  • There is absolutely no reason to call ActiveInspector (or ActiveExplorer) - th window is passed to your callback: use control.Context and cast it appropriately: it will be either Inspector or Explorer object.

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    • Marked as answer by PasBle Wednesday, February 27, 2019 9:42 AM
    Wednesday, February 27, 2019 1:06 AM

All replies

  • There is absolutely no reason to call ActiveInspector (or ActiveExplorer) - th window is passed to your callback: use control.Context and cast it appropriately: it will be either Inspector or Explorer object.

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    • Marked as answer by PasBle Wednesday, February 27, 2019 9:42 AM
    Wednesday, February 27, 2019 1:06 AM
  • Hello Dmitry,

    thank you for your post. Your hint helped me to find a good solution.

    Public Function RibbonTabGetVisibility(ByVal control As IRibbonControl) As Boolean
    If TypeOf (Me._applicationObject) Is Microsoft.Office.Interop.Outlook.Application Then If Outlook.myOlApp Is Nothing Then _ Outlook.myOlApp = CType(Me._applicationObject, Microsoft.Office.Interop.Outlook.Application) If TypeOf (control.Context) Is Microsoft.Office.Interop.Outlook.Inspector Then Dim myInspector As Microsoft.Office.Interop.Outlook.Inspector myInspector = TryCast(control.Context, Microsoft.Office.Interop.Outlook.Inspector) If myInspector IsNot Nothing Then If TypeOf (myInspector.CurrentItem) Is Microsoft.Office.Interop.Outlook.MailItem Then Outlook.myMailItem = TryCast(myInspector.CurrentItem, Microsoft.Office.Interop.Outlook.MailItem) ElseIf TypeOf (myInspector.CurrentItem) Is Microsoft.Office.Interop.Outlook.AppointmentItem Then Outlook.myAppointmentItem = TryCast(myInspector.CurrentItem, Microsoft.Office.Interop.Outlook.AppointmentItem) ElseIf TypeOf (myInspector.CurrentItem) Is Microsoft.Office.Interop.Outlook.ContactItem Then Outlook.myContactItem = TryCast(myInspector.CurrentItem, Microsoft.Office.Interop.Outlook.ContactItem) ElseIf TypeOf (myInspector.CurrentItem) Is Microsoft.Office.Interop.Outlook.MeetingItem Then Outlook.myMeetingItem = TryCast(myInspector.CurrentItem, Microsoft.Office.Interop.Outlook.MeetingItem) ElseIf TypeOf (myInspector.CurrentItem) Is Microsoft.Office.Interop.Outlook.TaskItem Then Outlook.myTaskItem = TryCast(myInspector.CurrentItem, Microsoft.Office.Interop.Outlook.TaskItem) Else Return False End If End If End If ...

    Any clue why the ActiveInspector-function is giving Nothing during the first execution of the getVisible-callback function now and did give the corresponding Inspector-Item before?

    Nevertheless my problem is solved! :)

    KR, Pascal


    • Edited by PasBle Wednesday, February 27, 2019 9:48 AM
    Wednesday, February 27, 2019 9:47 AM
  • You can get null for ActiveInspector if the new inspector is not yet visible and Outlook is building its ribbon.

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Wednesday, February 27, 2019 1:18 PM