User-Controlled Visibility of Outlook CommandBars

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

User-Controlled Visibility of Outlook CommandBars
How do you persist the user-selected visibility state of an ADXOlExplorerCommandBar? 
craig_at_work




Posts: 8
Joined: 2011-04-12
good morning,

many of our users are still on outlook 2003 and 2007, which means that we expose some of our functionality via commandbars - ADXOlExplorerCommandBar specifically.

some of our users prefer to go via our outlook menu to access the functions they need, and would like to HIDE our toolbars to preserve screen real-estate.

the problem is these commandbars do not respect the user action of hiding them.

to demonstrate what i mean:

1. i create a new Add-In express project, specifying support for Outlook 2003+. i register it, configure, etc. so that it will work in outlook.
2. i add an ADXOlExplorerCommandBar, with the name "CommandBar One" - i add one button to this. no additional code and no non-default settings.
ie. the commandbar has the following settings
* Visible = true
* FolderName = *
* Temporary = true
3. i validate that it displays when i run

User added an image

the problem comes in when a user now wishes to hide this commandbar using the standard outlook commandbar customize function.
in this case,
1. while in Inbox, right-click on the commandbar panel background and select "CommandBar One" to untick
2. note the the commandbar is now not visible.
3. change folders to any other folder, say Sent Items - the commandbar is visible again.
4. return to Inbox, notice that the CommandBar is still present.


User added an image
User added an image

the expected behaviour is that, once hidden, the commandbar will remain hidden across all folders and even across outlook restarts. this is how outlook commandbars work.

i can hide the commandbars manually, using all the tricks available here on these forums
Here
and Here

but the problem with these (besides the unreliability of the Visible property or the having to change folders with FolderName, etc.), is that once "hidden", the user has no way of recalling these commandbars. they are simply not in the list of customizable commandbars.

User added an image

what am i missing here? how should be i handling the user-selected visibility state of these commandbars?

any help would be appreciated.

---
craig
---
craig
Posted 20 Aug, 2012 05:50:41 Top
Eugene Astafiev


Add-in Express team


Posts: 8540
Joined: 2007-07-25
Hi Craig,

Thank you for the detailed description of the issue.

This is how Outlook manages its command bars. The only possible way is to use the ExplorerBeforeFolderSwitch event and set the Visible and FolderName properties of the command bar like the How to hide a command bar? forum thread suggests.
.NET, Extended MAPI, Windows Phone & RT
Posted 20 Aug, 2012 09:34:25 Top
craig_at_work




Posts: 8
Joined: 2011-04-12
hi eugene,

thanks for the prompt response.

using the ExplorerBeforeFolderSwitch to manually manage visibility assumes that i know when the user hides/unhides the commandbar - how can i tell? is there an event that i can subscribe to that indicates when this happens?
and how do i preserve this state? do i need to manage these states myself?

and besides, as i pointed out above, once i set the Visible = False or FolderName = string.Emtpy props, the commandbar is no longer listed in the Customize menu. how would the user then get it back again?

this, by the way, is NOT how outlook works. i can take one of the "built-in" commandbars, such as "Advanced" or "Web" and hide/unhide as i please. this visibility is preserved across folder changes and across outlook restarts. i can at any time, right-click to get the Customize menu and unhide these Commandbars.

did i misunderstand what you meant by how Outlook manages it?

thanks,

---
craig
---
craig
Posted 20 Aug, 2012 12:21:29 Top
Eugene Astafiev


Add-in Express team


Posts: 8540
Joined: 2007-07-25
Hi Craig,

Please try to use the CommandBarsUpdate event of the ADXOutlookAppEvents component (in terms of Add-in Express; it corresponds to the OnUpdate event of the CommandBars class from the Office Object Model) to be notified about the changes in the UI.

The built-in command bars behaves differently due to the fact that the Office/Outlook Object Model doesn't provide any trivial way for hiding and showing custom command bars on the fly. You can try adding command bars manually using the CommandBars.Add method and then showing and hiding them dynamically.
.NET, Extended MAPI, Windows Phone & RT
Posted 21 Aug, 2012 10:26:13 Top