My First Excel AddIn Using VSTO

Visual Studio Tools for Office (VSTO) is a set of development tools available in the form of a Visual Studio add-in (project templates) and a runtime that allows Microsoft Office 2003 and later versions of Office applications to host the .NET Framework Common Language Runtime (CLR) to expose their functionality via the .NET type system.

Visual Studio Tools for Office (VSTO) is used extensively to customize Office applications, especially the UI. VSTO allows us to add/customise task panes that are impossible with Visual Basic for Applications (VBA). Using the ribbon designer in VSTO, Ribbons can be created or customized that make creating new groups and adding controls (Buttons, Checkboxes, DropDown) to the ribbon as intuitive as adding a control to a Windows Forms form, compared to VBA that uses RibbonX.

VSTO is a part of the Microsoft Visual Studio .Net suite used for developing application-level or document-level add-ins for Microsoft Office Word, Excel, Access and Outlook Applications. Microsoft launched VSTO in 2003 as an alternative to VBA. Programs written in VSTO are executed by a separate virtual machine called Common Language Runtime (CLR). Programs written in VSTO are stored in separate CLI assemblies associated with the documents using custom properties VBA code stored in the document file itself.

Why To use VSTO

To extend Office applications for several usages, VSTO can be used for example to create a custom ribbon, assist in validating and pre-populating an Excel sheet. Validate the data entered by the user and to trigger events on the change of data/sheet to ensure the correct data was entered by the user.

How to create Excel AddIn using Visual Studio

To create your first application-level Excel Add-In using VSTO, use the following procedure:

File -> New -> Project in Visual Studio 2010
  • Under installed templates go to Visual C# -> Office then select the Excel 2007/2010/2013 Add-In.

  • Name the solution and click OK (as shown below).
 Excel 3013
  • To insert a Ribbon Designer, select the created project in the Solution Explorer and go to:

    • Add -> New Item

  • Select Ribbon (Visual Designer) and Add ribbon Designer.


Once the Ribbon Designer has been added to the project, you will see a ribbon populated on the screen. Controls like buttons, button groups, edit boxes can be dragged from ToolBox and dropped onto the Ribbon Designer.
 
 
  •  Drag a button from the toolbar onto the ribbon.

  • Right-click on the button and go to properties.

  • Change the name and label of the button.

  • You can change the size of the button by changing the ControlSize property.

  • Double-click on the button to start writing your code.

ribbon

Summary:

This is all about how to create an application-level AddIn project using VSTO. We will be back with further interesting features and functionalities that can be done using VSTO.


Similar Articles