You create a Microsoft® Excel add-in by creating a workbook, adding code and custom toolbars and menu items to it, and saving it as an Excel add-in file.
To create an Excel add-in
1. Create a new workbook, add code to it, and create any custom toolbars or menu bars.
2. On the File menu, click Properties. In the DocumentName Properties dialog box, click the Summary tab, and then use the Title box to specify the name for your add-in, as you want it to appear in the Add-Ins dialog box.
3. Compile the Add-In project by clicking Compile Project on the Debug menu in the Visual Basic Editor.
4. If you want, you can protect the project from viewing as described in Securing an Access, Excel, PowerPoint, or Word Add-in's VBA Project.
5. Save the add-in workbook as type Excel add-in, which has the extension .xla.
Note When you are creating an Excel add-in, pay close attention to the context in which your code is running. When you want to return a reference to the add-in workbook, use the ThisWorkbook property, or refer to the workbook by name. To refer to the workbook that is open in Excel currently, use the ActiveWorkbook property, or refer to the workbook by name.
When you have saved the add-in, you can reopen it in Excel to make changes to the project. The saved add-in no longer has a visible workbook associated with it, but when you open it, its project is available in the Microsoft® Visual Basic® Editor.
Saving the add-in workbook as an Excel add-in sets the IsAddIn property of the corresponding Workbook object to True.
You can debug an Excel add-in while it is loaded. When you load an add-in, its project appears in the Solution Explorer in the Visual Basic Editor. If the project is protected, you must enter the correct password to view its code.
Excel Add-ins | Loading an Excel Add-in | Running Code Automatically When an Excel Add-in Is Loaded or Unloaded