Introduced in Excel 2007.
VSTO Add-ins must implement the IStartup interface.
More information on how to call code inside a VSTO Add-in from VBA can be found here.
More information on how to add Excel User Defined Functions to a VSTO Add-in can be found here.

Open Visual Studio 2022 as administrator.
New Project, C#, Windows, Office, Excel VSTO Add-in for Excel 2013 and newer versions.
Change the Name to "ExcelVSTOAddin".
Change the Location to somewhere on your C drive.
Check the .NET Framework version is correct and press OK.
The solution contains one project and that project contains a single source file called ThisAddIn.cs
Add the following MessageBox's to the Startup and Shutdown events.

namespace ExcelVSTOAddin 
    public partial class ThisAddIn
        private void ThisAddIn_Startup(object sender, System.EventArgs e)
            System.Windows.Forms.MessageBox.Show("fires when add-in is loaded");

        private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
            System.Windows.Forms.MessageBox.Show("fires when add-in is unloaded");

        private void InternalStartup()
             this.Startup += new System.EventHandler(ThisAddIn_Startup);
             this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);

Build the Solution

Select (Build > Build Solution).
This will add the Registry Entry required to load the add-in into Excel.
When you clean the solution the registry key will be automatically removed.
When you use this template you do not have to set the Properties, Debug tab, "start external program".
When you use this template you do not have to tick the Properties, Build tab, "Register for COM Interop".
If you want to debug your office add-in just add a break point before loading.

Load the VSTO Add-in

Select (Debug > Start Debugging).
Excel will open and the add-in will be automatically loaded.
You will see the following message appear when Excel is opened.

microsoft excel docs

You will see the following message appear when you close Excel.

microsoft excel docs


You can display the project properties by double clicking on the Properties folder.

microsoft excel docs

AssemblyInfo.cs - This file contains important attributes that are used to describe this assembly (title, description, version, comvisible, guid, etc)
Resources.resx - This file contains information from the Properties, Resources tab and should not be manually edited.
Settings.settings - This file contains information from the Properties, Settings tab and should not be manually edited.


In this folder you will see a list of all the .NET assembly references that are used within this project.
Some of these are general .NET framework libraries (such as System.Windows.Forms)
Others are specific VSTO libraries that would only be used when creating a VSTO solution.
All the following references will be added to the project automatically
This list depends on the specific version of Visual Studio and the version of Office and the .NET framework you are targeting.

Accessibility - (4.0.0)C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\
Microsoft.CSharp - (4.0.0)C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\
Microsoft.Office.Interop.Excel - (15.0.0)C:\Program Files (x86)\Microsoft Visual Studio\Shared\Visual Studio Tools for Office\PIA\
Microsoft.Office.Tools - (10.0.0)C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\
Microsoft.Office.Tools.Common - (10.0.0)C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\
Microsoft.Office.Tools.Common.v4.0.Utilities - (10.0.0)C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\
Microsoft.Office.Tools.Excel - (10.0.0)C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\
Microsoft.Office.Tools.v4.0.Framework - (10.0.0)C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\
Microsoft.VisualStudio.Tools.Application.Runtime - (10.0.0)C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\
Office - (15.0.0)C:\Program Files (x86)\Microsoft Visual Studio\Shared\Visual Studio Tools for Office\PIA\
stdole - (7.0.3300)C:\Program Files (x86)\Microsoft.NET\Primary Interop Assemblies\stdole.dll
System - (4.0.0)C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\
System.Core - (4.0.0)C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\
System.Data - (4.0.0)C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\
System.Data.DataSetExtensions - (4.0.0)C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\
System.Drawing - (4.0.0)C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\
System.Windows.Forms - (4.0.0)C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\
System.Xml - (4.0.0)C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\
System.Xml.Linq - (4.0.0)C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\

© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext