Several users have reported that if they launch Excel by double-clicking an Excel file, the add-in will not load. But, if they open Excel via the Start menu (or Quick launch toolbar) the add-in loads fine.
Some details, in case they help:
- It is a COM add-in, written in VB6.
- The problem has been reported on Windows XP/Excel 2003 and Vista/Excel 2007 systems.
- The add-in implements IDTExtensibility2.
- The start mode is set to "Load on Startup".
Any thoughts on the cause or how to troubleshoot this would be greatly appreciated.
Update: I believe I have found a solution to this problem.
When an IDTExtensibility2 dll is registered, it automatically creates HKCU entries for the load behavior, add-in name, etc. But I also had my setup file register the add-in to HKLM, so that it would be available to all users on a machine. This caused double registry entries on the system.
I didn't think this would be the cause of the problem. I manually edited the HKCU entries and Excel seemed to ignore them and follow the HKLM entries. However, I received a tip from another developer explaining that they had the same problem, and their solution was to delete the duplicate registry entries. I tried it and it seems to have resolved the problem for the (very small number of) people who reported the bug.
The Inno Setup code below will add the HKLM entries, double-check that the load behavior is correct (because I'm paranoid), then delete the HKCU entry. Substitite your file attributes wherever you see ALL CAPS.
[Registry]
Root: HKLM; Subkey: Software\Microsoft\Office\Excel\Addins\CONNECT_CLASS; Flags: uninsdeletekey
Root: HKLM; Subkey: Software\Microsoft\Office\Excel\Addins\CONNECT_CLASS; ValueType: string; ValueName: FriendlyName; ValueData: ADDIN_NAME
Root: HKLM; Subkey: Software\Microsoft\Office\Excel\Addins\CONNECT_CLASS; ValueType: string; ValueName: Description; ValueData: ADDIN_DESC
Root: HKLM; Subkey: Software\Microsoft\Office\Excel\Addins\CONNECT_CLASS; ValueType: dword; ValueName: LoadBehavior; ValueData: 3
Root: HKLM; Subkey: Software\Microsoft\Office\Excel\Addins\CONNECT_CLASS; ValueType: dword; ValueName: CommandLineSafe; ValueData: 0
// Set load behavior to on start up
procedure ResetAddinRegKeys();
var
bUpdate : Boolean;
LoadBehaviorKey : Cardinal;
begin
if RegQueryDWordValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\Office\Excel\Addins\CONNECT_CLASS', 'LoadBehavior', LoadBehaviorKey) then begin
if LoadBehaviorKey <> 3 then begin
bUpdate := True;
end;
end else begin
bUpdate := True;
end;
if bUpdate = True then begin
RegWriteDWordValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\Office\Excel\Addins\CONNECT_CLASS','LoadBehavior', 3);
end;
if RegKeyExists(HKEY_CURRENT_USER, 'SOFTWARE\Microsoft\Office\Excel\Addins\CONNECT_CLASS') then begin
if RegDeleteKeyIncludingSubkeys(HKEY_CURRENT_USER, 'SOFTWARE\Microsoft\Office\Excel\Addins\CONNECT_CLASS') then begin;
//MsgBox('Duplicate keys deleted', mbInformation, MB_OK);
end;
end;
end;
function GetCustomSetupExitCode: Integer;
begin
ResetAddinRegKeys;
Result := 0;
end;
For my MSI installer, I have the commit section of the installation call the following VBScript:
Sub RemoveAddinHKCUKeys()
On Error Resume Next
Dim WshShell
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.RegDelete "HKCU\SOFTWARE\Microsoft\Office\Excel\Addins\CONNECT_CLASS\CommandLineSafe"
WshShell.RegDelete "HKCU\SOFTWARE\Microsoft\Office\Excel\Addins\CONNECT_CLASS\Description"
WshShell.RegDelete "HKCU\SOFTWARE\Microsoft\Office\Excel\Addins\CONNECT_CLASS\FriendlyName"
WshShell.RegDelete "HKCU\SOFTWARE\Microsoft\Office\Excel\Addins\CONNECT_CLASS\LoadBehavior"
WshShell.RegDelete "HKCU\SOFTWARE\Microsoft\Office\Excel\Addins\CONNECT_CLASS\"
If Err.Number <> 0 The Err.Clear
End Sub