Browse DevX
Sign up for e-mail newsletters from DevX


Create Your Own VB Add-Ins

Why should you create Add-Ins? We programmers always feel that we are short of several features while working with Microsoft tools, it seems that Microsoft hasnt yet developed the tool we needed. This article shows you how you can use the IDE's Extensibility Object Model to design your own add-in.




Building the Right Environment to Support AI, Machine Learning and Deep Learning

Why should you create Add-Ins? We programmers always feel that we are short of several features while working with Microsoft tools, it seems that Microsoft hasn’t yet developed the tool we needed. In fact, Microsoft has done a wonderful job of adding new features to each release of its development tools. Obviously, Microsoft can’t design features to fulfill the needs of each and every programmer around the world so Microsoft made Visual Basic and extensible product, thereby providing the way for VB developers to create their own features in VB.

What is EOM?

EOM Stands for Extensibility Object Model. You might ask what is extensibility? Extensibility is the capability to extend, stretch, the functionality of different development tools, specifically, Microsoft Integrated development environment (IDE). The IDE provides you with a programming interface known as the extensibility object model, a set of powerful interfaces for customizing the environment. It allows you to hook into the IDE to create extensions known as Add-Ins. A good system is the one which can be extended without jeopardizing the primary functionality of the system.

To implement extensibility features, VB offers the powerful Extensibility Object Model. Through EOM, many core objects in VB itself are available to you at no extra charge. EOM is not that easy to learn, this article will provide you only the basics of Add-in creation, you will have to delve into this vast field yourself to explore the wonders you can do using the EOM.

EOM consists of six loosely couple packages of objects with methods that implement key services of the VB development model. These are:

  • Core Objects

  • Form Manipulation

  • Event Response

  • Add-In Management

  • Project and Component Manipulation

  • Code Manipulation

Core Objects

This package is the main package used in the creation of Add-Ins. It has the following objects:

  • The root object

  • The IDTExtensibility Interface object

  • The Visual Basic instance variable

The Root Object

VBE is the root object in Visual Basic. The VBE object is the base object for every extensibility object and collection in Visual Basic. Each object and collection owns a reference to the VBE property. The collections owned by the VBE object include the following:

  • VBProjects

  • Windows

  • CodePanes

  • CommandBars

The VBProjects Collection

This collection enables you to access a set of VB properties. This feature can be helpful if your development environment has an established process for developing software. Some of the key properties and methods of this collection are:

Filename: returns the full pathname of the group project file

Startproject: returns or sets the project that will start when users choose start menu from the run menu, click the run button, or press F5 key.

AddFromFile: This is a method that enables the users to add or open a project or group object. Its only required argument is the string representing the path of the file you want to add.

AddFromTemplate: This method enables you to add project templates into the VBProjects collection. Its only required argument is the string representing the path of the file you want to use as a template.

The Windows Collection

With the windows collection, you can access the windows such as the project and properties windows. This collection enables you to access a group of all currently open code windows and designer windows.

The IDTExtensibility Interface Object

The IDTExtensibility Interface Object exposes the public methods and properties of the extensibility model. By exposes, I mean that because you don’t directly use the services, methods and properties of the underlying extensibility model, you need to invoke the methods of the model’s agent, so to speak. You can think of interfaces as public agents for the private implementation of an extensibility model object you instantiate.

The Visual Basic Instance Variable

This is also known as dynamic identification variable. It identifies a particular instance of your VB session. This instance identifier enables you to have separately identifiable running instances of VB in memory.

The instance variable is of the type VBIDE.VBE. To use this variable, declare it in a class module or general module.

Please refer to Microsoft website (http://www.microsoft.com) for complete details of these packages. Please understand that I can not explain each and every detail of these packages in this short article. Lets get started with the creation of the Add-In.

We will build a simple Add-In that will count the number of lines of code for a given program component.

To begin creating the Add-In, start a new project. Choose the AddIn project type. The AddIn project type includes many components necessary for creating VB Add-Ins. There is a form that you can modify to provide a user interface for your Add-In. There is also a designer module that contains the four methods that are needed for the Add-In’s interface to VB.

Remove the Ok and Cancel buttons from the form and add the following controls to the form:

Control Type








Code Line Counter
























Count Code Lines












Code Lines




Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date