AddIns 对象 (Excel)AddIns object (Excel)

AddIn 对象的集合, 该集合代表所有可用于 Microsoft Excel 的加载项, 而不管它们是否已安装。A collection of AddIn objects that represents all the add-ins available to Microsoft Excel, regardless of whether they're installed.

说明Remarks

此列表与 “加载宏” 对话框中显示的加载宏列表对应。This list corresponds to the list of add-ins displayed in the Add-Ins dialog box.

示例Example

使用应用程序属性返回AddIns集合。Use the Application property to return the AddIns collection. 下例创建了一个列表,包含所有可用加载宏的名称和安装状态。The following example creates a list that contains the names and installed states of all the available add-ins.

Sub DisplayAddIns() 
 Worksheets("Sheet1").Activate 
 rw = 1 
 For Each ad In Application.AddIns 
 Worksheets("Sheet1").Cells(rw, 1) = ad.Name 
 Worksheets("Sheet1").Cells(rw, 2) = ad.Installed 
 rw = rw + 1 
 Next 
End Sub

使用add方法可将外接程序添加到可用加载项列表中。add方法将加载项添加到列表中, 但不安装加载项。Use the Add method to add an add-in to the list of available add-ins. The Add method adds an add-in to the list but doesn't install the add-in. 将加载项的**已安装** 属性设置为True以安装加载项。Set the Installed property of the add-in to True to install the add-in.

若要安装不在可用加载项列表中显示的外接程序, 必须先使用add方法, 然后再设置已安装的属性。To install an add-in that doesn't appear in the list of available add-ins, you must first use the Add method and then set the Installed property. 此操作一步即可完成,如下例中所示(注意,Add 方法中应使用加载宏的名称,而不使用标题)。This can be done in a single step, as shown in the following example (note that you use the name of the add-in, not its title, with the Add method).

AddIns.Add("generic.xll").Installed = True

使用AddIns (索引), 其中_索引_是外接程序标题或索引号, 返回单个AddIn对象。Use AddIns (index), where index is the add-in title or index number, to return a single AddIn object. 下例安装“分析工具库”加载宏。The following example installs the Analysis Toolpak add-in.

AddIns("analysis toolpak").Installed = True

请勿混淆外接程序标题 (出现在 "加载项" 对话框中) 和外接程序名称, 即外接程序的文件名。Don't confuse the add-in title, which appears in the Add-Ins dialog box, with the add-in name, which is the file name of the add-in. 您必须完全按照 "加载项" 对话框中的内容拼写加载项标题, 但不需要匹配大小写。You must spell the add-in title exactly as it's spelled in the Add-Ins dialog box, but the capitalization doesn't have to match.

方法Methods

属性Properties

另请参阅See also

支持和反馈Support and feedback

有关于 Office VBA 或本文档的疑问或反馈?Have questions or feedback about Office VBA or this documentation? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.