Create Custom MS Word Ribbon Tab Using Ribbon XML In C#

Nilupul Nethsara
3 min readFeb 26, 2021

In this article I’m going to explain how to add a custom ribbon tab using the Ribbon (XML) item.

In order to complete this walkthrough you need following components :

Step 1 : Create a Project

The first step is to create a Word VSTO Add-In project. You can easily create it from File -> New -> Project and Search for Word VSTO Add-In.

Then click next and add any name you want in project name. Select .Net Framework version and click create.

Step 2 : Create a VSTO Add-Ins Tab

To add Ribbon (XML) right click on the project and select Add -> New Item. Search for Ribbon (XML) and Add it to the project.

Open ThisAddin.cs in solution explorer and add following code to it. This code overrides the CreateRibbonExtensibilityObject method and returns the Ribbon XML class to the Office application.

Step 3 : Customize your Ribbon

You can Edit Ribbon1.xml file as you wish and customize your ribbon according to your preferences. The bellow code show how to add simple button to your ribbon.

Add following function to the Ribbon1.cs and you can add any c# code to your function body. Make sure to add method name same in the onAction name in the Ribbon1.xml.

Step 4 : Build And Run

Build the code and Run it. In this example when you click on Test Button Message Box will appear.

I hope to continue writing regarding Office and SharePoint development in Visual Studio in my next articles.

Thank You for reading !

--

--