Conditional Inspector Commandbar

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

Conditional Inspector Commandbar
 
Rick Koch




Posts: 172
Joined: 2006-09-05
I'm using the beta VSTO product.

Is there any logic that will allow me to look at the item, during InspectorActivate(), to decide whether or not to display a toolbar? Sometimes I can't tell whether to display the toolbar until the item's been selected. Some mail items in the inbox would get a toolbar, while other items in the inbox would not. Is it possible to do this?

I realize I can turn off buttons individually during InspectorActivate(), but it appears that you can't control entire toolbars this way. I've tried both the enabled and visible properties.

Thanks in advance.
Posted 14 Sep, 2006 18:22:36 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi Rick.

The fact is that the InspectorActivate event fires when an Outlook item is openned/activated. So you need to use the ExplorerSelectionChange event instead. You can use the Selection property of the Outlook explorer to access the selected item. Then you can show/hide the command bar using the Visible property.
Posted 15 Sep, 2006 09:19:27 Top
Rick Koch




Posts: 172
Joined: 2006-09-05
I guess what you're telling me is to bypass the wrapper functionality, and to directly manage the toolbar's visibility in the Outlook Object Model by using the name specified in CommandBarName to access the relevant member of the inspector's CommandBars collection.

Since I'm interested in the inspector toolbar rather than the explorer toolbar, I'm not sure why I'd want to use the explorer selection change event. That event fires when browsing the list view from the explorer, even when no inspector is displayed. Selection change also does not fire when right-clicking the currently selected item and picking "open" from the context menu. So if you open an item using this method, the inspector toolbar visibility logic will not be applied to the resulting inspector if it's triggered by selection change.

On the other hand, there are two events in the inspector object that will fire when opening a new inspector or browsing through the folder with next item/ previous item buttons: Inspectors.NewInspector and Inspector.InspectorActivate (at least on my version of Outlook -- 2003). I've used these events to override individual button visibility through the ADX model, but it doesn't appear to override overall inspector commandbar visibility. Commandbar visibility seems firmly bound to foldername and itemtype. Unfortunately, sometimes there are more granular criteria for a commandbar. If I want an inspector commandbar only for items with a certain subject, or only for items from a certain sender, or only for items with a specific custom property, do I need to drop down to the OOM?
Posted 15 Sep, 2006 12:07:47 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi Rick.

I just thought that you were speaking about explorer command bars.
Of course, if you want to manipulate inspector command bars, you need to use the InspectorActivate event handler.
However there is an issue in Outlook object model. Sometimes Outlook caches its inspectors and you can face the situation when the command bar appears in the wrong inspector. So I would advise you not to hide/show the command bar and just enable/disable appropriate buttons on the command bar using the InspectorActivate event handler.
Posted 18 Sep, 2006 17:46:46 Top