title: Uninstalling Excel add-in using VBScript
body: <p>I'm trying to create a MSI installer that installs an Add-In (.xla) into Microsoft Excel (2007 in my case). Installing it goes well. I use a 'Custom Action' that runs this VBScript file:</p>
  
  <pre><code>Dim SourceDir
  Dim objExcel
  Dim objAddin
  
  SourceDir = Session.Property("CustomActionData")
  Set objExcel = CreateObject("Excel.Application")
  objExcel.Workbooks.Add
  Set objAddin = objExcel.AddIns.Add(SourceDir &amp; "addin.xla", True)
  objAddin.Installed = True
  objExcel.Quit
  Set objExcel = Nothing
  </code></pre>
  
  <p>I pass the location of the addin to the script using the CustomActionData property. The Add-in is copied to a folder inside 'Program Files', where it will stay until it is uninstalled. This is handled by the installer itself.</p>
  
  <p>The problem is when I use the uninstall script:</p>
  
  <pre><code>Dim objExcel
  Dim addin
  On Error Resume Next
  
  Set objExcel = CreateObject("Excel.Application")
  For i = 0 To objExcel.Addins.Count
      Set objAddin= objExcel.Addins.item(i)
      If objAddin.Name = "addin.xla" Then
          objAddin.Installed = False
      End If
  Next
  
  objExcel.Quit
  Set objExcel = Nothing
  </code></pre>
  
  <p>The addin creates a custom toolbar in Excel u[ installation. The toolbar is not removed upon uninstall, and the entry of the add-in in the 'Add-in' section of Excel's settings isn't either.</p>
  
  <p>Can anyone tell me if these two things can be done programmatically using VBScript?</p>
  
  <p>thanks in advance</p>