Description
Represents a single add-in, either installed or not installed.
Accessors
The AddIn object is a member of the AddIns collection. The AddIns collection contains a list of all the add-ins available to Microsoft Excel, regardless of whether they are installed. This list corresponds to the list of add-ins displayed in the Add-Ins dialog box (Tools menu). To access a single member of the collection, use the AddIns method with the add-in title or index number as an argument. Do not confuse the add-in title, which appears in the Add-Ins dialog box, with the add-in name, which is the filename of the add-in.
Use the Title property to return the title of the add-in (this property is read-only for add-ins). You must exactly match the spelling, but not the capitalization, of the title as it is shown in the Add-Ins dialog box. The following example installs the Analysis Toolpak add-in.
AddIns("analysis toolpak").Installed = True
The index number represents the position of the add-in in the list of add-ins shown in the Add-Ins dialog box. The following example creates a list on the worksheet named "Sheet1." The list contains specified properties of the available add-ins.
Sub EnumerateAddIns() Worksheets("sheet1").Rows(1).Font.Bold = True Worksheets("sheet1").Range("a1:d1").Value = _ Array("Name", "Full Name", "Title", "Installed") For i = 1 To AddIns.Count Worksheets("sheet1").Cells(i + 1, 1) = AddIns(i).Name Worksheets("sheet1").Cells(i + 1, 2) = AddIns(i).FullName Worksheets("sheet1").Cells(i + 1, 3) = AddIns(i).Title Worksheets("sheet1").Cells(i + 1, 4) = AddIns(i).Installed Next Worksheets("sheet1").Range("a1").CurrentRegion.Columns.AutoFit End Sub
Remarks
The Add method adds an add-in to the list of available add-ins but does not install the add-in. Set the Installed property of the add-in to True to install it. To install an add-in not shown in the list of available add-ins, you must first use the Add method and then set the Installed property. 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 the title, with the Add method):
AddIns.Add("generic.xll").Installed = True
Use the Workbooks method with the add-in filename (not title) to return a reference to the workbook corresponding to a loaded add-in. You must use the filename because loaded add-ins do not normally appear in the Workbooks collection. The following example sets the wb variable to the workbook for MYADDIN.XLA.
Set wb = Workbooks("myaddin.xla")
The following example sets the wb variable to the workbook for the Analysis Toolpak add-in.
Set wb = Workbooks(AddIns("analysis toolpak").Name)
If the Installed property returns True, but calls to functions in the add-in still fail, the add-in may not actually be loaded. This is because the Addin object represents the existence and installed state of the add-in but doesn't represent the actual contents of the add-in workbook (the add-in dialog sheets, worksheets, and so on).To guarantee that an installed add-in is loaded, you should open the add-in workbook. The following example opens the workbook for the add-in named "My Addin" if the add-in is not already present in the Workbooks collection.
On Error Resume Next ' turn off error checking Set wbMyAddin = Workbooks(Addins("My Addin").Name) lastError = Err On Error Goto 0 ' restore error checking If lastError <> 0 Then ' the add-in workbook isn't currently open. Manually open it. Set wbMyAddin = Workbooks.Open(Addins("My Addin").FullName) End If
While in a Visual Basic module, you create an add-in by clicking the Make Add-In command on the Tools menu. The AddIn object provides a programming interface to the Add-In Manager; it doesn't actually create an add-in.
Properties
Application Property, Author Property, Comments Property, Creator Property, FullName Property, Installed Property, Keywords Property, Name Property, Parent Property, Path Property, Subject Property, Title Property.