none
How to find the item of an open inspector window? RRS feed

  • Question

  • I am attempting to view and amend the fields within an inspector window programmatically with some commandbarbuttons created when a new inspector is created (only for tasks).

    The buttons are created fine the events and item type are processed fine (ie only tasks have buttons and they show a test msgbox) but I wish to modify the task when clicking these buttons after doing some checks within the system. Something like below.

    private sub tbbCheck_click()
        if check(inspector.currentitem) = true then
            inspector.currentitem.completed += 10
        end if
    end sub
    
    private function check(byval item as outlook.taskitem) as boolean
        if item.duedate < datetime.now then
            return true
        else
            return false
        end if
    end function

    How do I gain access to the item fields of the inspector window?

    Should I be using arguements in the handler declaration or perhaps just the click event?


    • Edited by _Ritchie_ Monday, June 25, 2012 10:56 AM Too brief
    Monday, June 25, 2012 9:52 AM

Answers

  • When you get NewInspector() you have to account for the possibility that more than 1 Inspector can be opened at a time. Many of us create wrapper classes that hold references to an Inspecor object and any buttons you create and the item in the Inspector. In that way when a button is clicked you get the event in the wrapper class and you already know what item fired the event.
     
    If there is no interest in doing that, you can use ActiveInspector().CurrentItem to get a handle to the item where the click occurred.
     
    If you create a CommandBarButton on an Inspector and don't set or make unique the Tag property of the button you can run into problems. If any open item has the same Tag property for its button then a click in one will fire the click event in all of the open items. That's usually not a good thing. The fix for that is to first use a unique Tag value for each open item, second is to use wrapper classes stored in a list that use a wrapper class key value to help populate the button Tag property so each Tag is unique.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "_Ritchie_" <=?utf-8?B?X1JpdGNoaWVf?=> wrote in message news:6f166fff-5ab2-446e-a268-936d3d83febc...

    That works fine for the NewInspector window stuff (how I have got different custom bars for different items).

    I was unclear in the previous post (sorry rushing for meeting). I was wondering for the button_click events as the arguements are not passed (as I see it although they may be if done correctly). The button click events do some checks and then should progress the .completed but without attaching to an item I am dumbstruck.

    Could I pass the item from the handler declaration?

    eg Addhandler tbbCheck.click, AddressOf tbbCheck_Click(inspector.currentitem)


    Ken Slovak MVP - Outlook
    • Marked as answer by _Ritchie_ Monday, June 25, 2012 1:51 PM
    Monday, June 25, 2012 1:31 PM

All replies

  • to gian access to item in inspector, use Inspector.CurrentItem, then you can use casting ('as' keyword in C#) to check if this is taskitem object.

    Monday, June 25, 2012 9:57 AM
  • That works fine for the NewInspector window stuff (how I have got different custom bars for different items).

    I was unclear in the previous post (sorry rushing for meeting). I was wondering for the button_click events as the arguements are not passed (as I see it although they may be if done correctly). The button click events do some checks and then should progress the .completed but without attaching to an item I am dumbstruck.

    Could I pass the item from the handler declaration?

    eg Addhandler tbbCheck.click, AddressOf tbbCheck_Click(inspector.currentitem)

    Monday, June 25, 2012 10:48 AM
  • let us start from some other point. Which outlook version should be supported and please describe in general words scenario that you want to achieve.
    Monday, June 25, 2012 12:05 PM
  • When you get NewInspector() you have to account for the possibility that more than 1 Inspector can be opened at a time. Many of us create wrapper classes that hold references to an Inspecor object and any buttons you create and the item in the Inspector. In that way when a button is clicked you get the event in the wrapper class and you already know what item fired the event.
     
    If there is no interest in doing that, you can use ActiveInspector().CurrentItem to get a handle to the item where the click occurred.
     
    If you create a CommandBarButton on an Inspector and don't set or make unique the Tag property of the button you can run into problems. If any open item has the same Tag property for its button then a click in one will fire the click event in all of the open items. That's usually not a good thing. The fix for that is to first use a unique Tag value for each open item, second is to use wrapper classes stored in a list that use a wrapper class key value to help populate the button Tag property so each Tag is unique.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "_Ritchie_" <=?utf-8?B?X1JpdGNoaWVf?=> wrote in message news:6f166fff-5ab2-446e-a268-936d3d83febc...

    That works fine for the NewInspector window stuff (how I have got different custom bars for different items).

    I was unclear in the previous post (sorry rushing for meeting). I was wondering for the button_click events as the arguements are not passed (as I see it although they may be if done correctly). The button click events do some checks and then should progress the .completed but without attaching to an item I am dumbstruck.

    Could I pass the item from the handler declaration?

    eg Addhandler tbbCheck.click, AddressOf tbbCheck_Click(inspector.currentitem)


    Ken Slovak MVP - Outlook
    • Marked as answer by _Ritchie_ Monday, June 25, 2012 1:51 PM
    Monday, June 25, 2012 1:31 PM
  • Once again Ken has the answer for this. In perfect detail and use. This time I'm proud to say I was already testing ActiveInspector when I came back though.
    Monday, June 25, 2012 1:52 PM