Click here to Skip to main content
12,622,913 members (30,177 online)
Rate this:
 
Please Sign up or sign in to vote.
Hi,

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)
        MyBase.Install(stateSaver)
 
        Dim targetDir = Me.Context.Parameters.Item("targetdir")
        targetDir = targetDir.Substring(0, targetDir.Length - 1)
        MsgBox(targetDir)
 
        Dim myScript = targetDir + "MySuperAddin.xll"
        MsgBox(myScript)
 
        Dim objAddin As Object
        Dim objEXL As Excel.Application = DirectCast(CreateObject("Excel.Application"), Excel.Application)
 
        objEXL.Workbooks.Add()
        Try
 
            objAddin = objEXL.AddIns.Add(myScript, True)
            objAddin(myScript).Installed = True
 
        Catch ex As Exception
            MsgBox("cannot open addin. /n Error: " + ex.Message)
Err_Handler:
            MsgBox(Err.Description, vbCritical, "Error: " & Err.Number)
        End Try
        objAddin = Nothing
        objEXL.Quit()
        objEXL = Nothing
    End Sub
End Class
 
<pre></pre>

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
http://stackoverflow.com/questions/1130301/uninstalling-excel-add-in-using-vbscript

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:
1) http://support.microsoft.com/kb/172108

and

2) http://support.microsoft.com/kb/213489/


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
tagad484
Comments
losmac 14-Feb-12 15:55pm
   
Which version of MS Excel?
Take a look here
tagad 16-Feb-12 8:41am
   
Hi,

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
 
good
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
 
        Try
            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)
 
        Finally
            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
 
        Try
            '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)
            oExc.Workbooks.Add()
            '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)
 
        Finally
            oExc.Quit()
            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.
  Permalink  

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 | Mobile
Web01 | 2.8.161128.1 | Last Updated 17 Feb 2012
Copyright © CodeProject, 1999-2016
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