How to position Outlook 2007/2010 VSTO Context Menu Button?

只愿长相守 提交于 2019-12-04 09:26:37

In Outlook 2003 and 2007, context menus were CommandBar-based, and created using code like the one you provided above. In Outlook 2010, context menus are now Ribbon-based, and typically declared using XML.

From Customizing Context Menus in Office 2010:

Prior to Microsoft Office 2010, the only way to customize context (right-click) menus in the Microsoft Office Fluent Ribbon user interface (UI) was by using CommandBars solutions. In Office 2010, you can customize built-in context menus just as you can the other components of the Ribbon UI. This XML-based context menu extensibility model is based on the familiar Ribbon extensibility model. This means that you can use the same XML markup and callbacks that you currently use to customize the Ribbon UI. Additionally, enabling context menu customizations through Ribbon UI extensibility does not “break” previously written command bar solutions.

Outlook 2010 supports backwards compatibility for CommandBar-based controls, but with some caveats; the inability to position the controls is probably one of them.

My suggestion would be to have your add-in detect whether the running Outlook version is 2003/2007 or 2010 and, in case of the latter, create Ribbon-based controls instead of the CommandBar-based ones. You will need to investigate how to adapt your code accordingly; for example, positioning may be performing by declaring insertBeforeMso attributes in the <button> element.

P.S. I would encourage you to consider switching to the commercial third-party product Add-in Express for Microsoft Office and .NET for extending the UI of Office applications; it simplifies the process drastically over VSTO. You would still need to create a separate ADXContextMenu (CommandBar-based) and AdxRibbonContextMenu (Ribbon-based), but the process may be done almost entirely using intuitive visual designers.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!