Develop Office Client Applications using Visual Studio
Office 2010 now lets you activate tabs on the Ribbon. I gave this a try in a Outlook 2010 project and was very pleased with how easy it was to accomplish. Here are a couple of back-of-the-napkin examples that I chicken scratched over lunch.
From the Ribbon Load event
This code activates (puts in focus) the built-in Add-Ins tab when the user creates a new mail message.
Public Class Ribbon1
Private Sub Ribbon1_Load(ByVal sender As System.Object, ByVal e As RibbonUIEventArgs) Handles MyBase.Load
Dim mailItem As Microsoft.Office.Interop.Outlook.MailItem = _
If Not (mailItem Is Nothing) Then
If mailItem.EntryID Is Nothing Then
public partial class Ribbon1
private void Ribbon1_Load(object sender, RibbonUIEventArgs e)
Microsoft.Office.Interop.Outlook.MailItem mailItem =
if (mailItem != null)
if (mailItem.EntryID == null)
From a Form Region
This code handles a button on an adjoining form region. The code activates a custom tab. Note that the only difference between this example and the previous one is that it uses the Globals class to access a Ribbon collection, and then gets the Ribbon of the active Inspector.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim RibbonCollection As ThisRibbonCollection = Globals.Ribbons _
private void button1_Click(object sender, EventArgs e)
ThisRibbonCollection ribbonCollection =
From Anywhere ..
So in honor of my favorite childhood author .. I will activate my Ribbon tabs with a mouse. I will activate them in a house. I will activate them here or there. I will activate them anywhere.
Wherever you are in your project (task pane, class file, etc.), just use the Activatexxx methods to activate your tabs. Oh and there is also a cool method named ActivateTabQ. However, I’ll leave that one for you. My lunch break is over :-)
asking for both VSTO 2008 , VSTO 2010
is it possible to make the button in ribbon-bar visible from windows Foms ?
I am not sure about this. This blog focuses mainly on ways to automate Office by using Office add-ins. It sounds like you are attempting to automate Office features (such as the Ribbon) by using applications that run apart from Office. To receive the best possible response, I recommend that you post this question to the Office Developer Forum - http://social.msdn.microsoft.com/Forums/en-US/categories.
Cool... but I need this in.. Office 2007! Thnk McFly, think!
Cripes, no hotfix for office 2007 yet?
I have used XML Ribbon and used the getVisibale call back function, for example:
public bool GetVisible( IRibbonControl control)
if (Globals.ThisAddIn.Application.ActiveInspector().CurrentItem is Outlook.PostItem)
Outlook.PostItem objPostItem = Globals.ThisAddIn.Application.ActiveInspector().CurrentItem as Outlook.PostItem;
For more information see: msdn.microsoft.com/.../ee390805%28office.11%29.aspx