Microsoft Office 2000/Visual Basic Programmer's Guide   

Deploying Application-Specific Add-ins

The AddIns folder under C:\Windows\Application Data\Microsoft or C:\Windows\Profiles\UserName\Application Data\Microsoft is the default folder for Word, Excel, PowerPoint, and Access application-specific add-ins. The simplest way to deploy an application-specific add-in, of course, is to e-mail the add-in to users or to post it on a network share with instructions for copying it to the correct folder. There is nothing wrong with this approach; however, you can't guarantee that users will copy the add-in correctly, especially if the add-in has any dependent files that may need to be installed to a different folder. If you need more control over the installation process, you can create a custom setup program to install the solution correctly.

Building such a setup program is relatively simple. Although you can build a setup program from any VBA host application, Microsoft Visual Basic is optimal because you can create an executable (.exe) file.

The trickiest part of building a custom setup program is determining the path to the Templates and AddIns folders on users' computers. To determine the location of the Templates and AddIns folders, you need to call three Windows application programming interface (API) functions. These functions are SHGetSpecialFolderLocation, SHGetPathFromIDList, and SHGetMalloc. For more information about working with the Windows API, see Chapter 10, "The Windows API and Other Dynamic-Link Libraries."

A template project for a custom setup program built in Visual Basic 6.0 is available in the ODETools\V9\Samples\OPG\Samples\CH02\CustomInstaller subfolder on the Office 2000 Developer CD-ROM. The instructions for using the template project to build a custom setup program are in the modInit module. If you don't have Visual Basic 6.0, you can still view and copy the code in the project's modules by opening them with Notepad.