Making the Visio ribbon tab document-dependent
This post explains how to make a ribbon tab in Visio 2010 ribbon document-specific. Means, activate a custom ribbon tab only for a specific document.
Download C# sample project (VS2008)
Download C++/ATL sample project (VS2008)
This article discusses the implementation of a document-specific tab in a COM add-in; also, it focuses on nasty details you might be interested in if you e.g. program unmanaged C++. Note that you could do this thing by other means, e.g. by embedding your custom interface in a document template using new Visio 2010 property Document.CustomUI.
Nevertheless, one of the ways to it is:
- Create a Visio add-in that supports ribbon (as described in previous post)
- Add onLoad event to the ribbon XML. This will allow you to obtain the ribbon manager.
<customUI onLoad="OnLoad" ...>
- In the event handler for the onLoad event, save passed-in ribbon manager. This is needed to force update of the ribbon.
// this function provides us with IRibbonUI object, called when XML is loaded public void OnLoad(object obj) { vsoRibbonUI = (Office.IRibbonUI) obj; }
Labels: C#, C++, Office 2010, Ribbon, Visio