Microsoft Office 2000/Visual Basic Programmer's Guide |
Some of the information about COM add-ins presented in this chapter may be easier to follow if you have a working COM add-in project to examine. For this reason, you may want to take time now to copy the files for the Image Gallery sample project from the ODETools\V9\Samples\OPG\Samples\CH11\ImageGallery subfolder on the Office 2000 Developer CD-ROM to your computer.
ImageGallery.vbp is a sample Microsoft Visual Basic 6.0 project that demonstrates the fundamentals of creating COM add-ins for Office 2000 applications. The Image Gallery add-in can be used from Word, Excel, or PowerPoint. It prompts the user to select a folder in the file system, and then displays thumbnails for the image files contained in that folder, of types bitmap (.bmp), Microsoft Windows metafile (.wmf), GIF (.gif), and JPEG (.jpg). When the user selects a thumbnail and clicks Insert, the graphic is inserted in the document, worksheet, or presentation in which he or she is working.
The Image Gallery project includes the components listed in the following table.
Component name | Description |
frmImageGallery | Form that prompts the user to select a folder containing graphics and insert an image in a document |
modSharedCode | Procedures called from all the add-in designers |
modFormFunctions | Procedures called from event procedures in the form's module |
dsrImageExcel | Add-in designer for the Excel version of the add-in |
dsrImagePpt | Add-in designer for the PowerPoint version of the add-in |
dsrImageWord | Add-in designer for the Word version of the add-in |
Before you can try the Image Gallery add-in, you must register it on your computer. Copy ImageGallery.dll from the ODETools\V9\Samples\OPG\Samples\CH11\ImageGallery subfolder on the Office 2000 Developer CD-ROM to your computer. On the Windows Start menu, click Run, and type the following command line to register the DLL, where path is the path to which you've copied ImageGallery.dll:
Regsvr32 path\ImageGallery.dll
If you have Visual Basic 6.0, you can also open the ImageGallery.vbp project in Visual Basic 6.0 and click Make ImageGallery.dll on the File menu to make the DLL. This process registers the DLL and also adds information to the registry necessary for Office to recognize this COM add-in.