Hiding/Showing command bar based on type of explorer in Outlook

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

Hiding/Showing command bar based on type of explorer in Outlook
 
Guest


Guest


I'm writing an Outlook add-in that only works on emails, appointments, and tasks. Therefore, I only want my command bar to appear in explorers and inspectors for those items. I thought that setting the item types in my command bar buttons would do this, but it doesn't. My command bar always appears regardless of the type of explorer/inspector I'm in. What am I missing? Thanks.
Posted 11 Oct, 2005 18:24:51 Top
Sergey Grischenko


Add-in Express team


Posts: 7225
Joined: 2004-07-05
Hi.

I guess that you use the ADXCommandBar component to add a new command bar in Outlook. But in order to manage buttons in Outlook you should use the ADXOlExplorerCommandBar and ADXOlInspectorCommandBar components.
Use the ItemTypes property of these components to make them visible in Outlook explorers/inspectors.
Posted 12 Oct, 2005 07:49:22 Top
Guest


Guest


Sergey,

Thanks - that solved the problem. But there's still one glitch:

I created my adxOlExplorerCommandBar and configured it to appear only for Mail items, but it appears when Outlook Today is selected. This is in Outlook 2003. How can I fix this? Thanks.
Posted 12 Oct, 2005 11:41:56 Top
Sergey Grischenko


Add-in Express team


Posts: 7225
Joined: 2004-07-05
Hi.

It happens because Outlook Today is the same thing as the Personal Folders.
In this situation I would suggest two solutions:
1.You enumerate all folders in which you would like to show the
command bar in the FolderNames property of the ADXOlExplorerCommandBar
component
2. You can disable the command bar manually in the code.
E.g. you can use the code below in the ExplorerFolderSwitch event
handler of the addinmodule:

Outlook._Explorer exp = explorer as Outlook._Explorer;
if (exp.CurrentFolder.Name == "Personal Folders")
adxOlExplorerCommandBar1.Enabled = false;
Posted 12 Oct, 2005 15:01:48 Top
Guest


Guest


Thanks Sergey. Through some trial and error I found a solution that works no matter what the folders are named:

try
{
outlook = (Outlook.Application) this.HostApplication;
Outlook.Explorer exp = outlook.ActiveExplorer();
// This operation throws an exception if Outlook Today is showing.
String s = exp.CurrentView.ToString();
}
catch (Exception e)
{
olMailExplorerCommandBar.Enabled = false;
}
Posted 13 Oct, 2005 14:21:18 Top
Sergey Grischenko


Add-in Express team


Posts: 7225
Joined: 2004-07-05
Ok, let me know if you face any other difficulties with Outlook.
Posted 13 Oct, 2005 15:36:33 Top