An easy distributed program build using VBA programming. Addins are very powerful utilities supported by Excel or other office programs. 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’re installed. This list corresponds to the list of add-ins displayed in the Add-Ins dialog box. Usually excel addins are having extensions as .xla, .xlam.
Installable location: There are two location of excel addins depending on the version of Office and Windows which can be accessed via following code:
Application.LibraryPath Returns: C:\Program Files\Office 2007\Office12\LIBRARY Application.UserLibraryPath Returns: C:\Users\Pearson\AppData\Roaming\Microsoft\AddIns
How to Install an Addin?: following code ensures that it automatically picks MyFirstAddIn.xls from “D:\ Drive” and installs in the Excel environment:
Sub InstallAddIn() Dim objExcelAddin As Excel.AddIn Set objExcelAddin = Application.AddIns.Add(Filename:="D:\MyFirstAddIn.xla") objExcelAddin.Installed = True End Sub
How to load an existing Addin?:
Sub InstallAddIn() ************************************ ' Installed = True to load Add In, ' Installed = False to unload Add In ************************************ Application.AddIns("Add-In Displayed Name").Installed = True ' or False End Sub
Public Sub CheckApplication() Set myObject = ActiveWorkbook If myObject.Application.Value = "Microsoft Excel" Then MsgBox "This is an Excel Application object." Else MsgBox "This is not an Excel Application object." End If End Sub
CLSID: Returns a read-only unique identifier, or CLSID, identifying an object, as a String.
Creator: Returns a 32-bit integer that indicates the application in which this object was created. Read-only Long. Return value XlCreator.
Note: If the object was created in Microsoft Excel, this property returns the string XCEL, which is equivalent to the hexadecimal number 5843454C. The Creator property is designed to be used in Microsoft Excel for the Macintosh, where each application has a four-character creator code. For example, Microsoft Excel has the creator code XCEL.
FullName: Returns the name of the object, including its path on disk, as a string. Read-only String.
Public Sub CheckAddin() Dim a As AddIn 'Iterate each addin For Each a In AddIns MsgBox a.FullName Next a End Sub
Installed: returns True if the add-in is installed, returns False if the add-in is not installed.
Note: Setting this property to True installs the add-in and calls its Auto_Add functions. Setting this property to False removes the add-in and calls its Auto_Remove functions.
Public Sub CheckAddin() Set a = AddIns("Solver Add-In") If a.Installed = True Then MsgBox "The Solver add-in is installed" Else MsgBox "The Solver add-in is not installed" End If End Sub
IsOpen: Returns True if the add-in is currently open. Boolean Read-only.
Name: Returns a String value that represents the name of the object.
Parent: Returns the parent object for the specified object. Read-only.
Path: Returns a String value that represents the complete path to the Add-in , excluding the final separator and name of the Add-in.
progID: Returns the programmatic identifiers for the object. Read-only String.
Public Sub WriteProgId() Dim rw As Integer rw = 0 For Each obj in Worksheets(1).OLEObjects With Worksheets(2) rw = rw + 1 .cells(rw, 1).Value = obj.ProgId End With Next End Sub
Addins2 Object: A collection of AddIn objects that represent all the add-ins that are currently available or open in Microsoft Excel, regardless of whether they are installed.
Note: The contents of the AddIns2 collection correspond to the list of add-ins displayed in the Add-Ins dialog box ( Add-Ins command on the Developer tab) and any add-ins that are currently open.
Difference between Addins and Addins2 Object:
- Addins object lists all the installed addins in current open application
- Addins2 lists all the addins available in current application
Next>> Advanced VBE Automation