Users commonly interact with setup programs to install new applications and components on their computers. When your COM add-in is ready to be distributed to other users, you can use the Package and Deployment Wizard that's installed by Visual Basic 6.0 or Office 2000 Develper. The Package and Deployment Wizard allows you to create a setup program that you supply to your users so that they can install your add-in.
Depending on the initial load behavior of the add-in, the next rime a user starts an Office application that the add-in targets, the add-in will be available. The following example steps through the use of the Package and Deployment Wizard in order to package the basic COM add-in created in this chapter.
NOTE
Before you package and deploy your COM add-in, make sure the initial load behavior of your COM add-in is set appropriately; that is, according to the functionality the add-in provides.
If the source files are newer than the previously compiled project, the wizard displays a dialog box indicating that the source files are newer and asks if you want to recompile. If you want the latest changes in your packaged solution, click Yes.
If a compiled file exists and is the most up-to-date, the Package and Deployment wizard displays another dialog box with a series of steps. The first step is selecting a package type.
In most cases, the best place to place the package is in a subfolder named Package in the folder containing your compiled .dll and source files. The Package and Deployment wizard automatically selects this folder by default.
The file associated with the file listed as VB6 Runtime and OLE Automation is Msvbvm60.dll. You don't need to redistribute this file because Office always installs it. Its size is 1.3MB, and it will add to the size of the package that the wizard creates.
Often, other files listed in this dialog box are object libraries. If you made a reference to any of the Office object libraries, including any of the following, it will appear in the dialog box:
If these files are listed, clear them. (Because they're part of the Office install, your package doesn't need to redistribute them.)
NOTE
If you are using a service pack of Visual Basic 6.0 or a service release of Office 2000, you may find that your machine has a newer version of the VB6 Runtime file Msvbvm60.dll than your user's machine. The newer version of the VB6 Runtime file may have some fixes that your COM add-in requires. Make sure you fully test your add-in with the Office application. If you find that your add-in doesn't work for some reason on another user's machine (one that doesn't have Visual Basic 6.0 installed), package the VB6 Runtime from your installation of Visual Basic.
The string $(ProgramFiles) represents a token indicating the Program Files folder. Setup uses the token because the full path to the Program Files folder on the user's machine may differ. The subfolder information added to $(ProgramFiles) indicates that the subfolder BasicCOMAddIn will be created and the files will be copied to that location.
Note that the Start Menu Items step is skipped. This step allows you to list items that would appear on the Windows Start menu after setup is complete. But because your COM add-in is loaded only through Office, no items are required on the Start menu.
The script is a file that saves the settings made in the Package and Deployment wizard. The script is useful the next time you need to create a package containing the exact same files and settings—but with a newly compiled COM add-in .dll file.
The report saved is a text file containing information about where your package is found and about a batch file that allows you to recreate the cab file quickly when you make changes to some of the files.
On the location specified in the Package folder step of the wizard, you'll find a CAB file, a Setup.exe file and Setup.lst. The Setup.exe program requires the LST file. The CAB file contains all of the files associated with your COM add-in, along with other files the setup program requires.
Most users won't change the default directory listed. This directory is the one you entered in the Install Locations step of the wizard.