title: Excel Add-ins installed programmatically are not loaded
body: <p><strong>Question Summary:</strong>
  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?</p>
  
  <p><strong>Details:</strong>
  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. </p>
  
  <p>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 <code>HKCU\...\Excel\Add-in Manager</code> - the list of add-ins remains identical to what it was before the run. </p>
  
  <p>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 <code>.xlsm</code> file...</p>
  
  <p><strong>Notes:</strong> </p>
  
  <ol>
  <li><p>The add-ins are not placed in Excel's Add-in directory but in a project folder (C:\appname\Addins\date).</p></li>
  <li><p>I use Excel 2010 on Windows 7 and have admin privilege on my machine. </p></li>
  <li>It's not a matter of Registry write access, since the same add-ins, if installed using the Excel UI are registered correctly under <code>HKCU\...\Excel\Add-in Manager</code>.</li>
  </ol>
  
  <p><strong>Please help resolve this mystery!</strong></p>
  
  <p>Code section which does the uninstalling:</p>
  
  <pre><code>    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=" &amp; appName, methodName
              End If
          Next appName
      Next ad
  </code></pre>
  
  <p>Code section which does the installation of the add-ins:</p>
  
  <pre><code>For Each file In addinFiles
      curAddInPath = pAddinDir &amp; file
      With Application.AddIns.Add(fileName:=curAddInPath)
          .Installed = True
      End With
  Next file
  </code></pre>