+ Reply to Thread
Results 1 to 6 of 6

Installing an Add-in from outside Excel

  1. #1

    Installing an Add-in from outside Excel

    I would like to to add an Add-in to Excels Add-in list and activate it
    from outside of Excel, specifically using an installer program. The
    only registry entry that I can find
    (HKEY_CURRENT_USER\Software\Microsoft\Office\10.0\Excel\Add-in Manager)
    has a list of Add-ins but changing it does not appear to have any
    effect. Does anyone know how to do this?

    Thanks, Seisman.


  2. #2
    Robin Hammond
    Guest

    Re: Installing an Add-in from outside Excel

    Siesman,

    The simplest way to do this is to launch Excel and install the add-in using
    Excel automation. Excel will then handle any reg entries you need. This is
    from a larger VB installation routine that handles file installation using
    the windows installer, and registration of the add-ins. I've clipped bits of
    this so haven't bothered with all the declarations which I am sure you can
    fill in.

    'larger routine has calls that look like this
    Sub Control
    If InstallMSI("myInstallerFile.msi") = false then
    'installation failed, handle it
    End If
    InstallAddIn
    End Sub

    Sub InstallAddIn()
    'this might fail if the user has insufficient machine rights
    'I did it this way to avoid problem with environ on WinNT
    strAddInPath = GetRegSetting(HKEY_LOCAL_MACHINE, _
    "Software\Microsoft\Windows\CurrentVersion", "ProgramFilesDir",
    "C:\Program Files")
    strAddInPath = strAddInPath & "\MyProgramName"
    strAddInPath = strAddInPath & "\MyAddIn.xla"

    nExcelCount = 0
    TestForExcel:
    On Error Resume Next
    Set oXL = GetObject(, "Excel.Application")
    On Error GoTo 0
    If Not (oXL Is Nothing) Then
    If nExcelCount = 0 Then
    Call MsgBox("Please save any files and quit Microsoft Excel then
    press OK", _
    vbOKOnly, msgTitle)
    Else
    Call MsgBox("You still have Excel running. To register this add-in
    with Excel " & _
    "you need to exit Excel first" & vbCrLf & vbCrLf & _
    "If you can't see a running instance of Excel you may have a
    hidden instance running" & vbCrLf & vbCrLf & _
    "To close a hidden instance, press ALT-CTRL-DEL and remove Excel
    from the list of running processes", _
    vbOKOnly + vbInformation, msgTitle)
    End If
    nExcelCount = nExcelCount + 1
    Set oXL = Nothing
    GoTo TestForExcel
    End If

    Set oXL = CreateObject("Excel.Application")
    'must have a workbook open to use this
    oXL.Workbooks.Add
    Set oAddin = oXL.addins.Add(strAddInPath)
    oAddin.installed = True
    oXL.Quit
    Set oXL = Nothing
    Call MsgBox("Install complete", vbInformation + vbOKOnly, "Enhanced
    Datasystems")
    End Sub

    And to launch an msi installer within the same vb project you can use
    something like this:

    Private Sub InstallMSI(strMSI As String) As Boolean
    Dim oWI As WindowsInstaller.Installer
    On Error Resume Next
    Set oWI = CreateObject("WindowsInstaller.Installer")
    On Error GoTo 0
    If oWI Is Nothing Then
    Call MsgBox("You must have the Microsoft Windows Installer system " & _
    "installed for this installation to work" & l2 & "Please contact " &
    _
    "your IT department and notify them of this message", vbCritical,
    msgTitle)
    Install = False
    Exit Function
    End If
    On Error GoTo ErrHandler
    oWI.InstallProduct (strMSI)
    On Error GoTo 0
    Install = True
    EndRoutine:
    Set oWI = Nothing
    Exit Function
    ErrHandler:
    On Error GoTo 0
    Err.Clear
    Install = False
    Resume EndRoutine
    End Function

    Robin Hammond
    www.enhanceddatasystems.com

    <[email protected]> wrote in message
    news:[email protected]...
    >I would like to to add an Add-in to Excels Add-in list and activate it
    > from outside of Excel, specifically using an installer program. The
    > only registry entry that I can find
    > (HKEY_CURRENT_USER\Software\Microsoft\Office\10.0\Excel\Add-in Manager)
    > has a list of Add-ins but changing it does not appear to have any
    > effect. Does anyone know how to do this?
    >
    > Thanks, Seisman.
    >




  3. #3
    okaizawa
    Guest

    Re: Installing an Add-in from outside Excel

    Hi,

    in excel 2000, 'OPEN' and 'OPENn' (n is a number from 1) in
    HKEY_CURRENT_USER\Software\Microsoft\Office\9.0\Excel\Options
    have add-in's path that will be opened automatically.

    --
    HTH,

    okaizawa


    [email protected] wrote:
    > I would like to to add an Add-in to Excels Add-in list and activate it
    > from outside of Excel, specifically using an installer program. The
    > only registry entry that I can find
    > (HKEY_CURRENT_USER\Software\Microsoft\Office\10.0\Excel\Add-in Manager)
    > has a list of Add-ins but changing it does not appear to have any
    > effect. Does anyone know how to do this?
    >
    > Thanks, Seisman.



  4. #4
    seisman
    Guest

    Re: Installing an Add-in from outside Excel

    Thanks Robin,
    In a similary way to your technique I use Tarma Installer to create
    installation packages and that uses a Shell call to run any program or
    document you specify at the end of the installation. I use that to run
    an "Activate.xls" workbook with code in the AutoOpen subroutine to
    install and activate the addin in Excel. I was hoping to streamline
    this a bit by accessing the registry directly (something that the Tarma
    Installer allows you to do). Okaizawa's post provides the clue to
    dointg this however it is not as straight forward as I had hoped as you
    have to count thenumber of OPEN keys in the
    HKEY_CURRENT_USER\Software\Mic=ADrosoft\Office\10.0\Excel\Option=ADs
    folder and add the next one in the sequence. Tarma allows you to link
    a dll to the installation routines it produces so I'd probably be able
    to do it that way. (I Downloaded XspandXL by the way - it looks
    interesting).
    Seisman.


  5. #5
    seisman
    Guest

    Re: Installing an Add-in from outside Excel

    Thanks okaizawa, that was the path I was looking for. Unfortunately
    it makes things a bit more complicated that I had hoped as the
    installation program that I am using will only allow me to add a fixed
    path. It will allow a .dll to be linked to it so it can probably be
    done that way.
    Thanks again,
    Seiscons


  6. #6
    Robin Hammond
    Guest

    Re: Installing an Add-in from outside Excel

    seisman,

    It's not just the issue of enumerating the registry keys, you also have to
    watch out for version differences if you try and do it direct. The technique
    I use (I think I probably found the base idea in one of Stephen Bullen's
    books then elaborated it a bit), works across NT, 2000, XP and Excel
    97-2003.

    Robin Hammond
    www.enhanceddatasystems.com

    "seisman" <[email protected]> wrote in message
    news:[email protected]...
    Thanks Robin,
    In a similary way to your technique I use Tarma Installer to create
    installation packages and that uses a Shell call to run any program or
    document you specify at the end of the installation. I use that to run
    an "Activate.xls" workbook with code in the AutoOpen subroutine to
    install and activate the addin in Excel. I was hoping to streamline
    this a bit by accessing the registry directly (something that the Tarma
    Installer allows you to do). Okaizawa's post provides the clue to
    dointg this however it is not as straight forward as I had hoped as you
    have to count thenumber of OPEN keys in the
    HKEY_CURRENT_USER\Software\Mic*rosoft\Office\10.0\Excel\Option*s
    folder and add the next one in the sequence. Tarma allows you to link
    a dll to the installation routines it produces so I'd probably be able
    to do it that way. (I Downloaded XspandXL by the way - it looks
    interesting).
    Seisman.



+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1