VSTO Add-in

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 2019 as administrator.
New Project, Visual C#, Office/SharePoint, VSTO Add-ins, Excel 2013 and 2016 VSTO Add-in.
Change the Name to "ExcelVSTOAddin".
Change the Location to somewhere on your C drive.
Check the .NET Framework version is correct at the top 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);

Registry Keys - VSTO Addin

Microsoft VSTO add-ins are identified by reading from the registry.
You can view the registry by going to the Windows start menu, choosing Run, typing regedit and pressing OK
There must be a key representing the VSTO add-in under the Addins key
64 Bit Office - Root\Software\Wow6432Node\Microsoft\Office\application name\Addins\add-in ID
32 Bit Office - Root\Software\Microsoft\Office\application name\Addins\add-in ID

Load the VSTO Add-in

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


You can display the project properties by double clicking on the Properties folder.
AssemblyInfo.cs - After building this solution a dll (or assembly file) will be created. 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 -  
Microsoft.CSharp -  
Microsoft.Office.Interop.Excel -  
Microsoft.Office.Tools -  
Microsoft.Office.Tools.Common -  
Microsoft.Office.Tools.Common.v4.0.Utilities -  
Microsoft.Office.Tools.Excel -  
Microsoft.Office.Tools.v4.0.Framework -  
Microsoft.VisualStudio.Tools.Application.Runtime -  
Office -  
stdole -  
System -  
System.Core -  
System.Data -  
System.Drawing -  
System.Windows.Forms -  
System.Xml -  
System.Xml.Linq -  

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