Registry Keys


Terminology

Not Installed - the ".xlam" or ".xla" file has been removed from the computer or shared drive.
Available - the ".xlam" or ".xla" file exists on the computer or shared drive.
Not Ticked - the add-in is available but has not been loaded in to Excel.
Loaded - the add-in is ticked and provides additional functionality.


Add-in Manager Key

The Add-in Manager key indicates that an add-in appears on the list in the Add-ins dialog box.
There can be entries here that point to files that are Not Installed.
This is updated when Excel closes.

Excel 2016 - HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Excel\Add-in Manager 
Excel 2013 - HKEY_CURRENT_USER\Software\Microsoft\Office\15.0\Excel\Add-in Manager
Excel 2010 - HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Excel\Add-in Manager
Excel 2007 - HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Excel\Add-in Manager

Any add-ins that have been added under the "Options" key and then manually unticked by the user are removed from the "Options" key and added here.


Options Key

The Options key indicates that an add-in is installed and will be Loaded the next time Excel opens.
This is updated when Excel closes.
If an add-in has just been ticked by the user, the registry entry will be moved from the Add-in Manager part of the registry to the Options" part of the registry when Excel closes.

Excel 2016 - HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Excel\Options 
Excel 2013 - HKEY_CURRENT_USER\Software\Microsoft\Office\15.0\Excel\Options
Excel 2010 - HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Excel\Options
Excel 2007 - HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Excel\Options

If the full path is not specified then the default folder location is "C:\Users\ "username" \AppData\Roaming\Microsoft\AddIns"


Installation and Automatic Loading

If you want an Excel add-in to appear automatically the next time they open their Excel you need to add an entry under the Options Key.
It is quite common for installers to create a registry key in this location.
The following script is VB Script that will add the corresponding registry entry under Options.

Const EXCEL_ADDIN_PATH_BEFORE = "HKCU\Software\Microsoft\Office\" 
Const EXCEL_ADDIN_PATH_AFTER = "\Excel\Options\"
Const ADDIN_REG_VALUE = """C:\Program Files (x86)\Better Solutions Limited\MyExceAddin.xlam"""

Function RegistrationKeyExists(key)
    On Error Resume Next
    objShell.RegRead (key)
    If Err = 0 Then
        RegistrationKeyExists = True
    Else
        RegistrationKeyExists = False
    End If
End Function

Function RegistrationKeyValueGet(name)
    On Error Resume Next
    Dim value
    value = objShell.RegRead(name)
    If Err = 0 Then
        RegistrationKeyValueGet = value
    Else
        RegistrationKeyValueGet = ""
    End If
End Function

Function RegistrationKeyValueSet(name, value)
    On Error Resume Next
    objShell.RegWrite name, value, "REG_SZ"
    If Err = 0 Then
        RegistrationKeyValueSet = True
    Else
        RegistrationKeyValueSet = False
    End If
End Function

Dim EXCEL_ADDIN_PATH
Dim versions
Dim officeval
Dim objShell
Dim count
Dim value
Dim exists
Dim success

Set objShell = CreateObject("WScript.Shell")

WScript.Echo "Excel Add-in Registration Tool"

versions = Array("12.0", "14.0", "15.0", "16.0") For Each officeval In versions
    EXCEL_ADDIN_PATH = EXCEL_ADDIN_PATH_BEFORE & officeval & EXCEL_ADDIN_PATH_AFTER

    WScript.Echo "Checking Office Version - " & officeval

    If RegistrationKeyExists(EXCEL_ADDIN_PATH) Then
        count = 0
        exists = False
        value = RegistrationKeyValueGet(EXCEL_ADDIN_PATH & "OPEN")

        While Len(value) > 0 And Not exists
            count = count + 1
            value = RegistrationKeyValueGet(EXCEL_ADDIN_PATH & "OPEN" & count)
            If value = ADDIN_REG_VALUE Then
                exists = True
            End If
        Wend

        If exists = True Then
            WScript.Echo "Office Version - " & officeval & " Already Registered"
        Else
            If count > 0 Then
                success = RegistrationKeyValueSet(EXCEL_ADDIN_PATH & "OPEN" & count, ADDIN_REG_VALUE)
            Else
                success = RegistrationKeyValueSet(EXCEL_ADDIN_PATH & "OPEN", ADDIN_REG_VALUE)
            End If
            If success Then
                WScript.Echo "Office Version - " & officeval & " Registration Complete"
            Else
                WScript.Echo "Office Version - " & officeval & " Unable to Register Add-In"
            End If
        End If
    Else
        WScript.Echo "Office Version - " & officeval & " Not Found"
    End If
Next
Set objShell = Nothing

HKEY_LOCAL_MACHINE

HKEY_LOCAL_MACHINE\Software\Microsoft\Office\Excel\Addins\
In Excel 2007 add-ins installed into local machine are also displayed in the COM add-ins dialog box.



© 2019 Better Solutions Limited. All Rights Reserved. © 2019 Better Solutions Limited TopPrevNext