Visual Basic Code of the Week (COTW)
Issue #96
Online Version at (paid subscribers only)
All content and source code is Copyright (c) 1999 by C&D Programming Corp. No part of this issue can be reprinted or distributed in any manner without express written permission of C&D Programming Corp. Word, Excel and Visual Basic are trademarks of Microsoft Corp.

Cool Software

Download a free copy of NetMon - Your Internet Performance Monitor at

New Visual Basic Site

We are looking for some qualified individuals to work on a new Visual Basic site. The first task is developing a high-quality resource guide for Visual Basic developers. This resource guide will be a well-organized list of web sites that have very good resources about Visual Basic (from beginners stuff through advanced with topics like MTS and ASP). It will gradually expand to include other resources such as free source code and online shopping of development tools. If you are interested in working on a web site dedicated to Visual Basic jump to and fill out the form online. Thanks!


In this Issue

In this issue we show how create an add-in for the Visual Basic environment. This is a simple add-in to easily close all opened code and designer windows.

Questions? Email us at

Close All Windows

The Close All Windows project shows how to create simple Add-Ins for use in the Visual Basic development environment.

To use this class you must add a reference to the Office library and the VB Extensibility library. Refer to the Requirements section above for specific names of these libraries.

We have made the complete project for this issue available online at

If you have any questions about using this class, let us know at

Important Information

There are not really any methods that need to be discussed to get this project to work. There are many comments explaining the details of the methods which VB calls to make your add-in work.

VB Add-Ins are typically ActiveX DLL's. You will notice in the CloseAllWindows project that the project type selected on the Project Properties option is ActiveX DLL. There is a single class defined called the Connect class. This is the class which the Visual Basic IDE expects to find in an add-in.

In order for your add-in to have a description when you select Add-Ins / Add-In Manager... you will need to update the Description property for this class in the Object Browser. You can do this by launching the Object Browser with the F2 key and selecting your project name from the top combo box (in this case CloseAllWindows). On the bottom half on the left side you will see a list of modules with Connect included in that list. Right-click on Connect and select Properties. Update the Description field with the description you want to appear in the Add-In Manager listing. This description can contain spaces.

Some information which is useful for understanding this issue is the concept of the Implements keyword. To get the add-in to work it must implement all the methods and properties exposed by the IDTExtensibility interface. This interface was written by Microsoft and defines the specific routines that you need to supply in order for your add-in to behave in the VB IDE. When you implement an interface all methods exposed by the interface must be defined. If you do not define all of them your project will not compile successfully.


See source code.

Sample Usage

This issue is a sample in and of itself. Refer to the source code included and more importantly the complete project at

Source Code

To see the source code for this issue you must be a subscriber to Code of the Week. If you are a subscriber the source code is available at the following address:

This document is available on the web

Paid subscribers can view this issue in HTML format. There is no additional source or information in the HTML formatted document. It just looks a little better since we have included some HTML formatting. Just point your browser to link at the top of this document.

Other links

Contact Information

C&D Programming Corp.
PO Box 20128
Floral Park, NY 11002-0128
Phone or Fax: (212) 504-7945