Export (0) Print
Expand All

Create a COM Add-in for Microsoft Project

Office 2000
This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

Developing and distributing a COM add-in is one way to provide users with a custom solution for Microsoft® Project 2000. An add-in extends Microsoft Project by adding functionality that is not in the core product. For example, an add-in might add new menu commands or toolbar buttons that display custom forms to add new features.

This article describes how you can use a Microsoft Visual Basic® designer template to quickly create a Component Object Model (COM) add-in for Microsoft Project 2000. The template allows you to add features to customize the add-in for your needs.

Code Center
   
The Visual Basic template files are available from the Microsoft Download Center.

Using the Visual Basic 6.0 Template Files

The Code Center includes a set of template files you can use for creating a COM add-in for Microsoft Project in Visual Basic. To use the template, download the self-extracting file from the Code Center, which installs the following files:

  • MyProjectAddIn.vbp
  • Connect.dsr
  • frmProjectAddIn.frm
  • MyProjectAddIn.res

The source code in the Connect.dsr designer module is heavily commented to help you add toolbars and custom menus, as well as locate string constants and variables. The Visual Basic form file, frmProjectAddIn.frm, has been set up with OK and Cancel buttons; however, the form can be extended as needed. The MyProjectAddIn project also contains a resource file, MyProjectAddIn.RES, which contains a sample bitmap. A resource file can store additional bitmaps, text strings, or other data as needed.

You can start a new project by opening the MyProjectAddIn.vbp project file in Visual Basic, or you can install the files as a template for multiple uses (see the following section, "Installing a Template in Visual Basic 6.0").

Installing a Template in Visual Basic 6.0

If you intend to create multiple add-ins for Microsoft Project, you can create your own template from these files to use in Visual Basic. After you install the template files, you can create a new COM add-in for Microsoft Project by using the New Project dialog box in Visual Basic. If you do not wish to install a template from these files, you can still customize the Code Center files for a single COM add-in by opening the MyProjectAddIn.vbp file and saving the project under a different name.

To install a new template in Visual Basic:

  1. Download the self-extracting zip file from the Microsoft Download Center.
  2. Copy the files MyProjectAddIn.vbp, Connect.dsr, frmProjectAddIn.frm, and MyProjectAddIn.res to the template directory for Visual Basic 6.0.
    The default template directory for Visual Basic 6.0 is
    C:\Program Files\Microsoft Visual Studio\VB98\Template\Projects.

Starting a New Project from a Template in Visual Basic

After you have installed the template files in the proper directory, you can select the Microsoft Project add-in template from the list of available projects.

To select the add-in template:

  1. On the File Menu, click New Project.
  2. In the New Project dialog box, click MyProjectAddIn.

The designer template organizes the project files into three folders: Forms, Designers, and Related Documents. If the directory structure is not visible, click Toggle Folders in the Project Explorer pane.

The source code of the add-in designer template, Connect.dsr, contains comments about required or suggested alterations. For example, the template includes a function for adding an entry to a menu item, a function for adding a new toolbar, and a function for adding a new toolbar item. You may want to use none, one, or all of these options depending on the functionality goal of the add-in you are creating.

The MyProjectAddIn template also includes a resource file, which allows you to collect all of the version-specific text and bitmaps for an application in one place. This can include icons, screen text, and other material that may change between localized versions or between revisions or specific configurations. You can create and edit a resource file by using the Resource Editor Add-in in Visual Basic 6.0.

To install and use the Visual Basic Resource Editor add-in:

  1. From the Add-Ins menu, click Add-In Manager.
  2. In the Available Add-Ins list, click VB 6 Resource Editor.
  3. Under Load Behavior, select the check boxes for the behaviors you want to enable for the Resource Editor add-in.
  4. On the Tools menu, click Resource Editor.
  5. In the VB Resource Editor dialog box, use the menu buttons to add cursors, icons, bitmaps, or custom resources, or to edit string tables.
  6. Click Save.
  7. In the Save Resource File As dialog box, type a name for the file, and then click Save.
    Visual Basic creates a folder called Related Documents, which contains your resource files.
    Note
       
    The resource file is not saved with the designer module and the Visual Basic form file when you save the project template files on your local machine. When starting a new project from the designer template, you should use the resource editor to save the resource file with the rest of the project.

Debugging a COM Add-in

When you're developing a COM add-in in Visual Basic, you can debug the add-in by putting the project into run mode. With the project in run mode, you can load and use the COM add-in from within Microsoft Project to test and debug it by using any of the Visual Basic debugging tools.

To debug a COM add-in:

  1. Open the add-in project in Visual Basic.
  2. In the Project Explorer, double-click the Connect.dsr designer module.
  3. On the View menu, click Code.
  4. Place a break point in the show function.
    Note
       
    To avoid inconsistent behavior in the way Visual Basic debugs COM add-ins, it is necessary to insert at least one break point in the show function before running the COM add-in in Microsoft Project.
  5. On the Run menu, click Start With Full Compile.
    This command compiles your project, alerting you of any compilation errors, and puts your project into run mode.
  6. Open Microsoft Project.
    When the add-in loads, the OnConnection event occurs. You can now enter break mode in the add-in project in Visual Basic 6.0 and debug the code.

For more information, see Debugging a COM Add-in.

Additional Information

The following articles provide more information on creating COM add-ins for Office applications, and the information can be applied to creating a COM add-in for Microsoft Project.

Building COM Add-ins for Office Applications

COM Add-ins Part I: Introducing an Office 2000 Solution for the Entire (Office) Family

HOWTO: Build an Office 2000 COM Add-in in Visual Basic

Add-ins, Templates, Wizards, and Libraries

Deploying COM Add-ins

Show:
© 2014 Microsoft