You can create a COM add-in for Office 2000 in any programming language that lets you create a COM .dll or COM .exe file. These languages include Microsoft Visual C++, Visual J++, Visual Basic version 5.0 or higher (Professional or Enterprise Edition), and the version of Visual Basic for Applications included in Microsoft Office 2000 Developer. The examples in this chapter use Visual Basic version 6.0.
To create a simple COM add-in for Office 2000 using Visual Basic version 6.0, complete the following steps:
Property | Value |
---|---|
Addin Display Name text box | Type Microsoft Office Basic COM add-in for Word. |
Application drop-down list | Microsoft Word |
Application Version drop-down list | Microsoft Word 9.0 |
Initial Load Behavior drop-down list | None |
The COM add-ins dialog box displays the "friendly name" of the add-in, which is "Microsoft Office Basic COM add-in for Word." The Application drop-down list contains the applications for which you can register your COM add-in. COM add-ins are supported in Office 2000 and later versions. If you have Office 2000 installed on your machine, each Office 2000 application will be listed. The Initial Load Behavior drop-down list at the bottom of the General tab allows you to set how your add-in loads. Chapter 14, in the section "COM Add-in Load Behavior Settings," describes the different load behaviors in more detail.
The default load behavior in the General tab is set to None; consequently, the add-in won't automatically load when you start Word. Instead, you have to load the add-in using the COM Add-Ins dialog box. The next section, "Test the COM Add-in," describes how to use the COM Add-Ins dialog box.
MsgBox "Add-in connected to: " & Application.Name |
MsgBox "Add-in disconnected" |
The project name represents the first part of the programmatic identifier (ProgID) of your COM add-in. The ProgID lets you uniquely identify your COM add-in.
NOTE
Programmatic identifiers are described in the next chapter.
File | File name | Extension |
---|---|---|
Add-in Designer | ConnectWord | .dsr |
Project | BasicCOMAddIn | .vbp |
The next step is for you to test your COM add-in.
When you compile the .dll, it's automatically registered in the Windows system registry. Because of the Add-in Designer, the add-in is registered where the Office application (such as Word) will know to load it.
In Word, the COM Add-Ins command is listed at the top of the Commands list box. However, the COM Add-Ins command is not listed in the same position in the Commands list box of every Office application, so you'll then need to scroll down the list.
The following message box appears. Click OK to dismiss it.
The COM add-in you created is now compiled as a .dll file, registered, and available on your computer. When your add-in is fully developed and debugged, you'll need to package and deploy it—that is, make it available to other users. The last section of this chapter describes how to deploy your COM add-in so that you can register and install it on any user's machine.