5

Currently I'm writting VB functions and save them as an Excel addin .xlam file.

I want to have a .bat script so as to quickly deploy those addins.

Currently, to activate my .xlam addins, I have to Open Excel - File - Option - Addins - Browse to addin files... as below screenshot. This is absolutely manual, repeated & tiring thing to do.

So my need is to automate the activation process.

enter image description here

halfer
  • 19,824
  • 17
  • 99
  • 186
Nam G VU
  • 33,193
  • 69
  • 233
  • 372

3 Answers3

2

I was looking for exactly the same sort of thing this morning. I will eventually try something like this out, but I haven't yet. So, here is what I have come to so far:

http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.addins2.add.aspx

This is an example about how to use Excel automation from C#. From what I see, all these automation interfaces are really COM interfaces, so you are not restricted to C# or Visual Basic (maybe you can use some fancy scripting of Windows to work with them? what I will try is to use python with pywin32, but that's only because it suits my taste).

Then, for registering the addin(s), check this method:

http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.addins2.add.aspx

I actually saw an example somewhere about how to use it, but I can't find it right now.

Anyway, these are just ideas. I'm very interested on knowing how it all ends ;-)

dsign
  • 12,340
  • 6
  • 59
  • 82
1

you can insert this code in your *.xlam in the sheet "ThisWorkBook" this code install and activate the current AddIns, just by opening

Private Sub Workbook_Open()
    Dim oXL As Object, oAddin As Object
    URL = Me.Path & "\"
    normalUrl = Application.UserLibraryPath ' Environ("AppData") & "\Microsoft\AddIns"
    AddinTitle = Mid(Me.Name, 1, Len(Me.Name) - 5)

    If URL <> normalUrl Then
        If MsgBox("Can you Install AddIns ?", vbYesNo) = vbYes Then
            Set oXL = Application ' CreateObject("Excel.Application")
            oXL.Workbooks.Add
            Me.SaveCopyAs normalUrl & Me.Name
            Set oAddin = oXL.AddIns.Add(normalUrl & Me.Name, True)
            oAddin.Installed = True

            oXL.Quit
            Set oXL = Nothing
        End If
    End If
End Sub
-2

After one manually added time, we can update the addin by copy the addin file to Excel addin lair. Here is the .bat script to do it.

set       fipAddin=".\FIPphase2.xlam"
set excelAddinLair="%APPDATA%\Microsoft\AddIns"

copy %fipAddin% %excelAddinLair%

Hope it helps!

Nam G VU
  • 33,193
  • 69
  • 233
  • 372