Saturday, September 24, 2016

VBA code to list all add-ins in the workbook!!!

Add-ins is very useful functionality in excel application. Which helps user to implement specific calculation or requirement for a specific dataset. Add-ins is nothing but a generic macro which is created to perform specific task in excel as same as excel macro. Sometimes, we need details of specific Add-ins which is being used in excel workbook. In this article, we will see how to get details of each add-ins using a excel macro.














Here is the code which will give us list and details of each add-ins in the workbook:

Sub Get_Addins_Details()
' Author: Dreams24
' Written for VBA Tricks and tips blog

Dim var_addin As AddIn
Dim i As Integer

On Error GoTo errHandlar:

ActiveWorkbook.Sheets("Sheet1").Cells(1, 1).Value = "Name"
ActiveWorkbook.Sheets("Sheet1").Cells(1, 2).Value = "Installed"
ActiveWorkbook.Sheets("Sheet1").Cells(1, 3).Value = "Is Open"
ActiveWorkbook.Sheets("Sheet1").Cells(1, 4).Value = "Path"

' Initialized value for incremental counter i
i = 1

' Loop to get each add-ins details
For Each var_addin In Excel.AddIns

    ActiveWorkbook.Sheets("Sheet1").Cells(i + 1, 1).Value = var_addin.Name
    ActiveWorkbook.Sheets("Sheet1").Cells(i + 1, 2).Value = var_addin.Installed
    ActiveWorkbook.Sheets("Sheet1").Cells(i + 1, 3).Value = var_addin.IsOpen
    ActiveWorkbook.Sheets("Sheet1").Cells(i + 1, 4).Value = var_addin.Path
    
    i = i + 1
Next var_addin

'Error handling code for runtime errors
errHandlar:
    If Err.Number > 0 Then
        MsgBox "An error has occured. See below error desciption for details." & vbNewLine & vbNewLine & "VBA Error No: " & Err.Number & vbNewLine & "VBA Error Description: " & Err.Description
    End If
    
MsgBox "Add-ins detail retreived successfully !!!", vbInformation, Title:="Add-ins List"

End Sub

1 comment:

Stephen Gay said...

No this is not correct, It gives the list of addins in the Addins collection; but does not include addins you may have opened via: File:Open