Click here to Skip to main content
13,254,754 members (51,302 online)
Rate this:
Please Sign up or sign in to vote.

I would like to register an XLL while installing a project using MSI.

I am using a VB.NET installer class to do this:
Imports System.ComponentModel
Imports System.Configuration.Install
Imports System.ArgumentException
Imports Microsoft.Office.Interop
Public Class Installer1
    Public Overrides Sub Install(ByVal stateSaver As System.Collections.IDictionary)
        Dim targetDir = Me.Context.Parameters.Item("targetdir")
        targetDir = targetDir.Substring(0, targetDir.Length - 1)
        Dim myScript = targetDir + "MySuperAddin.xll"
        Dim objAddin As Object
        Dim objEXL As Excel.Application = DirectCast(CreateObject("Excel.Application"), Excel.Application)
            objAddin = objEXL.AddIns.Add(myScript, True)
            objAddin(myScript).Installed = True
        Catch ex As Exception
            MsgBox("cannot open addin. /n Error: " + ex.Message)
            MsgBox(Err.Description, vbCritical, "Error: " & Err.Number)
        End Try
        objAddin = Nothing
        objEXL = Nothing
    End Sub
End Class

When I run this code as a VB script on my desktop I dont have any issue.

it is a very standard way to install an addin

please see the link

However when I run it during the installation I get

Error: 438 Member not found. (Exception from HRESULTS: 0x80020003 (DISP_E_MEMBERNOTFOUND))

I tried to find a solution using the following links:



but NO success. it is a clear problem with OLE Automation Object. I would really appreciate a suggestion. MANY THANKS!!
Posted 10-Feb-12 7:31am
losmac 14-Feb-12 15:55pm
Which version of MS Excel?
Take a look here
tagad 16-Feb-12 8:41am

Thanks for your reply.

It is interesting the fact that I created the very same above install class in C# and I don't get the error message any longer.

I am using Office 2003. The add-in is visible and (theoretically) installed in excel, but not working.

However if I untick the box of the excel add-in and I tick it back the add-in works, and its functions visible
among the excel functions.

When a XLL Add-in is installed on a user's system, registry entries are created for the Add-in.

Maybe the method Add of addins fails to create proper registry entries for the target addin and I need to
do it manually, by specifying on the user's system the addin PATH as environment variable or by defining the registry entries.

Help or ideas are very welcome.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Take a look at my code...

I have created windows application.
I have placed on the form:
1) 1x textbox - Name: TxtExcelAddin
2) 2x buttons: - a) CmdBrowse (browse for addin)
b) CmdInstall (install addin)

Public Class Form1
    Private Sub CmdBrowse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdBrowse.Click
        Dim dlgOF As OpenFileDialog = Nothing
        Dim dRes As DialogResult = Windows.Forms.DialogResult.No
            dlgOF = New OpenFileDialog()
            With dlgOF
                .Filter = "Excel 2003 Addin file (*.xla)|*.xla|Excel 2007 Addin file (*.xll)|*.xll"
                .FilterIndex = 0
                .Multiselect = False
                dRes = .ShowDialog()
                If dRes = Windows.Forms.DialogResult.OK Then Me.TxtExcelAddin.Text = .FileName
            End With
            Me.CmdInstall.Enabled = (Me.TxtExcelAddin.Text.Length > 0)
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Error no. " & Err.Number)
            dlgOF = Nothing
            dRes = Nothing
        End Try

    End Sub
    Private Sub CmdInstall_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdInstall.Click
        Dim oExc As Object = Nothing, oAds As Object = Nothing, oAin As Object = Nothing
        Dim sFileName As String = String.Empty
            'get the name of Addin
            sFileName = Me.TxtExcelAddin.Text
            'Excel application
            oExc = CreateObject("Excel.Application")
            'to add addin, we need to create new workbook (to enable Addin manager)
            'collection of Addins
            oAds = oExc.AddIns
            'add Addin to the list of Addins
            oAin = oAds.Add(sFileName, True)
            'install Addin
            oAin.Installed = True
            MsgBox("Excel Addin installed: " & oAin.Installed, MsgBoxStyle.Information, "Information...")
        Catch ex As ArgumentException
            MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Error no. " & Err.Number)
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Error no. " & Err.Number)
            oAin = Nothing
            oAds = Nothing
            oExc = Nothing
        End Try
    End Sub
End Class

I'm not using Interop and installer class. The code is executing without errors.
I hope it will be helpful for you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.171114.1 | Last Updated 17 Feb 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100