Archive: Excel Add-ins


Excel Add-ins
I used NSIS a few years ago to distribute an application and it worked very well. Now I am working on a small Excel add-in for a customer to distribute to their clients. I have become reacquainted with the scripting language and have learned about the modern UI (it looks great!). The only thing I am having trouble with is on the Microsoft end, registering the add-in. Has anyone done this with NSIS before?

Thanks,
Jeff


I think you'll have to write to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\Excel\Addins


Thank you for your suggestion. I will give it a try and let you know how it goes.

Jeff


Hi Jbaylor,

would you email me your script about excel add-in?
I have the same question.
I appreciate it very much.


sorry
I spent a few hours working on it and decided that I was spending more money than it was worth. I decided to just popup a CHM file with step-by-step instructions and images to guide the user through the final steps by hand (go to [Tools][Add-Ins], etc.). I investigated other add-ins and could not find a better way. If your add-in is COM based you should be able to use a registry approach, but I needed to keep the macros in VBA.

If anyone else has a solution, I am still very interested. I ran out of patience with it though.

Best of luck.

Regards,

Jeff Baylor
bConverged.com


My Add-ins works with .msi. But if I use nullsoft, it doesn't work. The registry shows that there is no different (the key is same) of both packages. I spent a week working on it and did not get solution. Who can help me?
I appreciate it very much.


Unless your add-in is COM-based, I do not think there is a registry solution. I spent a lot of time adding VBA add-ins and then diffing my registry and was not finding an answer. I am sure there is a way to do it, there are installation products that claim to, but I have not managed it yet. The path I started down which seemed to have the most potential was to write a COM app that would start an Excel process in the background and register it programmatically. I only allotted a fixed number of hours to the project and installing the add-in was taking up more time than writing it, so I stopped. If it is important to have the install done programmatically, I would write a C++ app that does it for you and call it from NSIS.

Good luck,

Jeff Baylor
bConverged.com


Jeff,
Yes. My add-in is COM-based. I also want to have the install done programmatically.
Thank you very much for your quickly response.


Check out these MS help pages. They may point you in the right direction.

http://msdn.microsoft.com/library/de...ExcelAddin.asp
http://support.microsoft.com/default...;EN-US;q280290

There is also a registry key which MS claims will have the add-ins listed. I suspect that this is only used for COM add-ins. I currently have three VBA add-ins loaded and this is empty.

HKEY_CURRENT_USER\Software\Microsoft\Office\10.0\Excel\Add-in Manager

Regards,
Jeff Baylor
bConverged.com


Jeff, Thank you so much for your help.

I still have trouble in NSIS.
I wrote my Add-In in .NET 2003 with C#.
It works well with .msi installer created by .NET 2003.
I want to use NSIS to create an installer of it.
However, the NSIS installer does not work ( there is no tool bar of my Add-In in Office application. I could see the tool bar if I used .msi installer.).
I'm wondering if I miss something in building NSIS installer. I added the key in NSIS script. I checked the registry. The key existed in registry. Could anyone give me some suggestions?

I appreciate it very much.


I think I got it. There's like 5 different places where UIDs are used to identify your plugin. My registry entries in NSIS ended up looking like this:
-----------------------------------------------------
WriteRegStr HKCU "Software\Microsoft\Office\Outlook\Addins\COMAddin.Connect" "FriendlyName" "COMAddin.Connect"
WriteRegStr HKCU "Software\Microsoft\Office\Outlook\Addins\COMAddin.Connect" "Description" "COMAddin.Connect"
WriteRegDWORD HKCU "Software\Microsoft\Office\Outlook\Addins\COMAddin.Connect" "LoadBehavior" "00000003"
WriteRegDWORD HKCU "Software\Microsoft\Office\Outlook\Addins\COMAddin.Connect" "CommandLineSafe" "00000000"

WriteRegStr HKCR "CLSID\{44408B38-B310-4BC9-9275-084BE741D1E5}" "" "COMAddin.Connect"
WriteRegStr HKCR "CLSID\{44408B38-B310-4BC9-9275-084BE741D1E5}\Implemented Categories\{40FC6ED5-2438-11CF-A3DB-080036F12502}" "" ""
WriteRegStr HKCR "CLSID\{44408B38-B310-4BC9-9275-084BE741D1E5}\InprocServer32" "" "$INSTDIR\COMAddin.dll"
WriteRegStr HKCR "CLSID\{44408B38-B310-4BC9-9275-084BE741D1E5}\InprocServer32" "ThreadingModel" "Apartment"
WriteRegStr HKCR "CLSID\{44408B38-B310-4BC9-9275-084BE741D1E5}\ProgID" "" "COMAddin.Connect"
WriteRegStr HKCR "CLSID\{44408B38-B310-4BC9-9275-084BE741D1E5}\Programmable" "" ""
WriteRegStr HKCR "CLSID\{44408B38-B310-4BC9-9275-084BE741D1E5}\TypeLib" "" "{CDC4D4CA-F710-42B3-A53E-4139A271AE24}"
WriteRegStr HKCR "CLSID\{44408B38-B310-4BC9-9275-084BE741D1E5}\VERSION" "" "1.0"
WriteRegStr HKCR "COMAddin.Connect" "@" "COMAddin.Connect"
WriteRegStr HKCR "COMAddin.Connect\Clsid" "@" "{44408B38-B310-4BC9-9275-084BE741D1E5}"
WriteRegStr HKCR "TypeLib\{CDC4D4CA-F710-42B3-A53E-4139A271AE24}\1.0" "" "COMAddin"
WriteRegStr HKCR "TypeLib\{CDC4D4CA-F710-42B3-A53E-4139A271AE24}\1.0\0\win32" "" "$INSTDIR\COMAddin.dll"
WriteRegStr HKCR "TypeLib\{CDC4D4CA-F710-42B3-A53E-4139A271AE24}\1.0\FLAGS" "" "0"
WriteRegStr HKCR "TypeLib\{CDC4D4CA-F710-42B3-A53E-4139A271AE24}\1.0\HELPDIR" "" "$INSTDIR"

WriteRegStr HKLM "CLSID\{44408B38-B310-4BC9-9275-084BE741D1E5}" "" "COMAddin.Connect"
WriteRegStr HKLM "CLSID\{44408B38-B310-4BC9-9275-084BE741D1E5}\Implemented Categories\{40FC6ED5-2438-11CF-A3DB-080036F12502}" "" ""
WriteRegStr HKLM "CLSID\{44408B38-B310-4BC9-9275-084BE741D1E5}\InprocServer32" "" "$INSTDIR\COMAddin.dll"
WriteRegStr HKLM "CLSID\{44408B38-B310-4BC9-9275-084BE741D1E5}\InprocServer32" "ThreadingModel" "Apartment"
WriteRegStr HKLM "CLSID\{44408B38-B310-4BC9-9275-084BE741D1E5}\ProgID" "" "COMAddin.Connect"
WriteRegStr HKLM "CLSID\{44408B38-B310-4BC9-9275-084BE741D1E5}\Programmable" "" ""
WriteRegStr HKLM "CLSID\{44408B38-B310-4BC9-9275-084BE741D1E5}\TypeLib" "" "{CDC4D4CA-F710-42B3-A53E-4139A271AE24}"
WriteRegStr HKLM "CLSID\{44408B38-B310-4BC9-9275-084BE741D1E5}\VERSION" "" "1.0"
WriteRegStr HKLM "SOFTWARE\Classes\COMAddin.Connect" "" "COMAddin.Connect"
WriteRegStr HKLM "SOFTWARE\Classes\COMAddin.Connect\Clsid" "" "{44408B38-B310-4BC9-9275-084BE741D1E5}"
WriteRegStr HKLM "TypeLib\{CDC4D4CA-F710-42B3-A53E-4139A271AE24}\1.0" "" "COMAddin"
WriteRegStr HKLM "TypeLib\{CDC4D4CA-F710-42B3-A53E-4139A271AE24}\1.0\0\win32" "" "$INSTDIR\COMAddin.dll"
WriteRegStr HKLM "TypeLib\{CDC4D4CA-F710-42B3-A53E-4139A271AE24}\1.0\FLAGS" "" "0"
WriteRegStr HKLM "TypeLib\{CDC4D4CA-F710-42B3-A53E-4139A271AE24}\1.0\HELPDIR" "" "$INSTDIR"
-----------------------------------------------------
Hope This Helps - Ryan


The previous post is wrong but I figured it out finally! Basically, you just register the dll and then you add a few registry entries under HKCU\Software\Microsoft\Office\Outlook\Addins\

The code looks like this:
-------------------------------------------------------
Exec 'regsvr32.exe /s "$INSTDIR\MyCOMAddIn.dll"'

WriteRegStr HKCU "Software\Microsoft\Office\Outlook\Addins\MyCOMAddIn.Connect" "FriendlyName" "MyCOMAddIn.Connect"
WriteRegStr HKCU "Software\Microsoft\Office\Outlook\Addins\MyCOMAddIn.Connect" "Description" "MyCOMAddIn"
WriteRegDWORD HKCU "Software\Microsoft\Office\Outlook\Addins\MyCOMAddIn.Connect" "LoadBehavior" "00000003"
WriteRegDWORD HKCU "Software\Microsoft\Office\Outlook\Addins\MyCOMAddIn.Connect" "CommandLineSafe" "00000000"
-----------------------------------------------
You would replace MyCOMAddIn with whatever you set your PROGID to be in your dll.

Sorry about the confusion - Ryan


A Simple Solution Using VBS
I also spent a lot of time looking for a solution. I was finally able to piece something together using a couple of simple VBS scripts and the nsExec plugin. I wrote one VB script to enable the plugin and another to disable the plugin. Here are the basic lines of VBS that enable the AddIn:

  Set objXL = WScript.CreateObject("Excel.Application")
objXL.AddIns("Addin Name").Installed = True
objXL.Quit

The .NSI has something like this:
  ;Copy the XLA Installer
File "${XLA_INSTALLER}"

;Execute the installer
nsExec::Exec '"$SYSDIR\wscript.exe" "$INSTDIR\${XLA_INSTALLER}"'

;Delete the installer
Delete "$INSTDIR\${XLA_INSTALLER}"

I've attached a zip with the .NSI script and the two VB scripts. To use it just modify the constants at the top of the .NSI file. I hope this helps someone some day. :) I know I was having the hardest time finding any help on it, so I wanted to be sure to document my solution somewhere.

I also recently tackled this problem. I looked into using a VBA installer to avoid having to tackle the Excel Add-in Manager registry mess. However, I was concerned that the VBA solution would not be robust. Default Office 2003 security settings will not even ask the user if they want to enable macros (VBA) so there's a good chance that the VBA code would not run.

I came up with the attached script to work with the registry and install the Add-in (I hope attaching scripts is acceptable in this forum?). This is my first installer script - it's not pretty but it seems to do the job. Any advice on improving the script is appreciated. I should mention that this is for installing a VBA Add-in, the registry keys are different for installing a COM Add-in.

PS: Also posting to microsoft.public.excel.programming newsgroup since I've seen this question asked several times without an adequate answer.

Dave


Thanks ggp!
dgp's solution works great! A much more elegant solution than what I did, by creating some vbs files to do the installation. Thanks for posting your .nsi!


additional Add-in info
Thanks dgp for the registration code.

One follow-up question, does anyone have any good suggestions on how to determine the Add-ins folder, where to extract the VBA add-in I'm installing? On XP and 2000 machines, it's C:\Documents & Settings\user\Application Data\Microsoft\Addins\, on Vista machines it's C:\Users\user\AppData\Roaming\Microsoft\Addins\. Is there anything like a "$ADDINDIR" system-defined directory, or do I have to code it manually?

Thanks,
Jon