Question Summary: Why do my add-ins which are installed programmatically do not load when I start Excel from Program Menu but are loaded when I open the Installer.xlsm workbook which installed them?
Details: My team develops a hierarchy of add-ins used by various users in our organization. I have an Installer.xlsm file which installs new versions for each of the add-ins. It has a Workbook_Open method which upon opening the workbook uninstalls currently installed versions of the add-ins and installs their newer versions.
This worked wonderfully for over a year. Recently we updated the hierarchy of the add-ins and since then the same script would run successfully, uninstalling old add-ins and installing new ones. However, when Excel is re-opened (from program menu or an existing workbook) it seems that the script had no effect at all - the add-ins that were installed before the run remain installed and the new add-ins are not even listed in the Manage Add-ins form. This is reflected also in HKCU\...\Excel\Add-in Manager
- the list of add-ins remains identical to what it was before the run.
However, if I open Installer.xlsm again - it loads only the add-ins I'd expect it to load after a successful script run (loads the newly installed add-ins and doesn't load the ones the script uninstalled)! It's as if the add-ins are installed in the scope of the single .xlsm
file...
Notes:
The add-ins are not placed in Excel's Add-in directory but in a project folder (C:\appname\Addins\date).
I use Excel 2010 on Windows 7 and have admin privilege on my machine.
HKCU\...\Excel\Add-in Manager
.Please help resolve this mystery!
Code section which does the uninstalling:
For Each ad In Application.AddIns
For Each appName In pAppNames
If pIniMap.item("FilePrefix").Exists(appName) Then
filePrefix = pIniMap.item("FilePrefix").item(appName)
If Left(ad.Name, Len(filePrefix)) = filePrefix Then
If ad.Installed Then
ad.Installed = False
Workbooks(ad.Name).Close False
End If
End If
Else
logger.Warn "Entry is missing for section FilePrefix, appName=" & appName, methodName
End If
Next appName
Next ad
Code section which does the installation of the add-ins:
For Each file In addinFiles
curAddInPath = pAddinDir & file
With Application.AddIns.Add(fileName:=curAddInPath)
.Installed = True
End With
Next file
Click the Office button, and then click Excel Options. Click Add-Ins. Under Manage, click Disabled Items, and then click Go. On the Add-Ins dialog box, if RUNNER for TRANSACTION appears in the list, select it.
To activate an Excel add-inClick the File tab, click Options, and then click the Add-Ins category. In the Manage box, click Excel Add-ins, and then click Go. The Add-Ins dialog box appears. In the Add-Ins available box, select the check box next to the add-in that you want to activate, and then click OK.
It may be that your adding from the default directory rather than the custom directory you specified. I added the argument below, in your installation code. Hopefully it helps.
For Each file In addinFiles
curAddInPath = pAddinDir & file
With Application.AddIns.Add(fileName:=curAddInPath, CopyFile:=False) 'add false to args if addin is not coming from default directory
.Installed = True
End With
Next file
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With