VB.Net - Project
Open Visual Studio 2022 as administrator.
New Project, Visual Basic, Windows, Office, Excel VSTO Add-in for Excel 2013 and newer versions.
Change the Name to "ExcelVSTOAddinVB".
Change the Location to somewhere on your C drive.
Check the .NET Framework version is correct and press Create.
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.
Public Class ThisAddIn
Private Sub ThisAddIn_Startup() Handles Me.Startup
System.Windows.Forms.MessageBox.Show("fires when add-in is loaded")
End Sub
Private Sub ThisAddIn_Shutdown() Handles Me.Shutdown
System.Windows.Forms.MessageBox.Show("fires when add-in is unloaded")
End Sub
End Class
Build the Solution
Select (Build > Build Solution).
This will add the Registry Entry required to load the add-in into Word.
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).
Word will open and the add-in will be automatically loaded.
You will see the following message appear when Excel is opened.
You will see the following message appear when you close Excel.
Project Files
AssemblyInfo.vb - 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.
Properties
You can display the project properties by double clicking on the My Project folder.
Application - (slightly different in C#)
Compile - (only in VB.Net)
Debug - (same as C#)
References - (only in VB.Net)
Resources - (same as C#)
Services - (same as C#)
Settings - (same as C#)
Signing - (same as C#)
My Extensions - (only in VB.Net)
Publish - (same as C#)
Code Analysis - (same as C#)
References
In this folder you will see a list of all the .NET assembly references that are used within this project.
These are exactly the same as C#.
© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext