Visual Basic Concepts
All add-ins, regardless of what they do, require that you reference the items discussed in this topic. When you begin an add-in project, selecting the add-in template that comes with Visual Basic will provide a project containing code for all of the items listed in this topic. The template is described in this topic.
All add-ins you create with Visual Basic require the following:
For More Information See "Visual Basic Instance Variable" in this chapter for information on using the VBE object.
Implements IDTExtensibility
The IDTExtensibility interface contains four methods for handling add-in events:
Although these are methods to the IDTExtensibility interface, to you as a programmer, they act exactly like events, triggering when an event occurs.
The IDTExtensibility interface speeds up the process of creating these four essential procedures and eliminates problems with add-ins due to entry errors in the parameter list, or other procedure syntax errors.
When you click the Objects drop down box in the code window for the class module, you'll see IDTExtensibility. When you select IDTExtensibility, the four required add-in event procedures appear in the Procedures drop down box. Simply click the name of each procedure to add it to the class module.
Since add-ins require that all members of an interface be implemented, the class module must contain all four procedures. You can add as many other procedures to the class module that you want, but you must have those four at a minimum for your add-in to work.
Note One important caveat is that each of the four procedures must contain at least one line of code, such as a statement, procedure call, comment, and so on. If the procedure is empty, it will be removed by the compiler. If you don’t have any particular code you want to put in these procedures, just insert a comment.
For More Information Add-in events are also covered in Chapter 4, "Connecting and Exposing Add-Ins" in the section "Connecting or Disconnecting Add-Ins." Other events that you'll want to handle are covered in this chapter under the section "Responding to Events."
To declare a Visual Basic instance variable in the declarations section of a module or class module, you might enter:
' The variable VBInst is set to the current instance ' of Visual Basic.
Global gVBInst As VBIDE.VBE
For More Information "Creating a Basic Add-In," in Chapter 1, "Add-Ins Overview," steps you through creating a simple add-in and provides a brief illustration of the items presented here at work together.
Visual Basic's add-in template contains the basic, necessary code that all add-ins require. To use the add-in template to create a new add-in project, choose Add-In in the New Project dialog box. This template contains the essentials:
The template also includes these other useful features:
The add-in template is a great starting point for your add-in projects.