Change sheet Tab color Excel Addin

Change sheet Tab color Excel Addin

VSTO C# offers power to change your sheet tab color to make identification of sheets more identical in nature. Following example changes sheet tab to blue color.

Prerequisites:

  • Visual Studio 2015 or above having Microsoft Office for Developer Tool installed
  • Create Excel Addin in C# code style (Visual Studio Tools for Office)
  • Create a ribbon designer and put button

Code example:

private void btnTabColor_Click(object sender, RibbonControlEventArgs e)
{
	//get reference of active worksheet
	excel.Worksheet oWorksheet = Globals.ThisAddIn.Application.ActiveWorkbook.ActiveSheet;
	//change sheet tab color to Blu
	oWorksheet.Tab.Color = excel.XlRgbColor.rgbBlue;
}

Output:

Next : check and change sheet protection using Excel C#

Leave a Reply

Your email address will not be published. Required fields are marked *