Microsoft Office 2000/Visual Basic Programmer's Guide | ![]() |
Office 2000 uses the new Microsoft Windows installer, which manages the process of installing Office on the user's computer. The Windows installer is an operating system component that is installed on your machine when you first begin the Office 2000 installation process. In future versions of Windows, the Windows installer will be a fundamental part of the operating system.
In previous versions of Microsoft Office, a product or feature can either be installed on the user's computer, or not installed. If your solution created with a previous version of Office uses a product or feature that may not be installed on a particular user's computer, you need to include error handling in your code for cases where the product or feature is unavailable.
In Office 2000, a feature can be installed, not installed, or advertised. An advertised feature is one that's installed the first time the user tries to use it. When you run the Office 2000 installation program and select the Install on First Use setting for a particular feature, the Windows installer installs the appropriate shortcuts and icons and registers the feature in the Windows registry, but doesn't actually install the feature itself.
When you're creating an Office 2000 solution, you may want to take into account the fact that certain features may be advertised on the user's computer. To specify that the Windows installer should install a given feature when you refer to it from code, you can use the FeatureInstall property of the Application object. This property is available in all Office 2000 applications.
By default, the FeatureInstall property is set to msoFeatureInstallOnDemand. With this setting, the Windows installer will install on the user's computer any advertised feature used by your code. The other settings for the FeatureInstall property are msoFeatureInstallNone, which instructs the Windows installer not to install advertised features, and msoFeatureInstallOnDemandWithUI, which gives the user the option to cancel the installation.
For example, the Office Assistant is a feature that may be advertised. If you want to use the Office Assistant in your solution, you can set the FeatureInstall property to instruct the Windows installer to install the Assistant if it's advertised, as shown in the following procedure:
Private Sub cmdOK_Click()
' Turns the Assistant on or off, depending on the user's choice
' and on the installation state for the Assistant.
Const ASST_NOT_AVAILABLE As Long = -2147467259
If optDisplayAsst.Value = True Then
' If Assistant is already installed, or not
' installed, setting the FeatureInstall property
' has no effect. The FeatureInstall property affects
' only advertised features.
Application.FeatureInstall = msoFeatureInstallOnDemandWithUI
' Turn on Assistant. If Assistant is not installed,
' or if user cancels installation, error will occur here.
On Error Resume Next
Assistant.On = True
' Handle the error. Note that the same error is returned
' whether the Assistant was not installed or the user
' cancelled the installation.
If Err.Number <> 0 Then
If Err.Number = ASST_NOT_AVAILABLE Then
MsgBox "Sorry, the Assistant is not currently available."
GoTo Event_End
End If
End If
Assistant.Visible = True
Else
' Turn Assistant off if it's on.
Assistant.On = False
End If
Event_End:
Unload Me
Exit Sub
End Sub
This procedure appears in the module for the frmDisplayAsst UserForm in the DisplayAssistant.doc sample file, which is available in the ODETools\V9\Samples\OPG\Samples\CH02 subfolder on the Office 2000 Developer CD-ROM.
For more information about managing the Windows installer from within Office solutions, see Installer.doc in the OPG\Appendixes folder on the Office 2000 Developer CD-ROM.