Deploying Excel Add-In using NSIS - Registry issue
Asked Answered
E

1

6

I created a test project in VS 2012

file -> new -> project -> Other Languages -> Visual C# -> Office -> 2010

which builds fine. I would like to deploy this on client machines, looking on the MSDN website I have 2 options, clickonce or installshield

https://msdn.microsoft.com/en-us/library/bb386179(v=vs.110).aspx

I can't use clickonce, and I have been asked not to use installshield but NSIS. I have made progress with NSIS but it fails to register the dll. If I try and manually register it using Regsvr32, I will get an error message

"The module "[filepath]TestAddin.dll" was loaded but the entry-point DLLRegisterServer was not found. Make sure that "[filepath]TestAddin.dll" is a valid DLL or OCX file and then try again.

here is how I try and register within the NSIS script, taken from an old forum page which I don't fully understand.

  Exec 'regsvr32.exe /s "$INSTDIR\MyExcelAddin.dll"'

  WriteRegStr HKLM "Software\Microsoft\Office\Excel\Addins\MyExcelAddin.Connect" "FriendlyName" "MyExcelAddin"
  WriteRegStr HKLM "Software\Microsoft\Office\Excel\Addins\MyExcelAddin.Connect" "Description" "MyExcelAddin"
  WriteRegDWORD HKLM "Software\Microsoft\Office\Excel\Addins\MyExcelAddin.Connect" "LoadBehavior" "00000003"
  WriteRegDWORD HKLM "Software\Microsoft\Office\Excel\Addins\MyExcelAddin.Connect" "CommandLineSafe" "00000000"

Update: I can now create registry entries doing the following but the add-in still won't show up in excel

  SetRegView 64
  Exec '"%SystemRoot%\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe" "$INSTDIR\MyExcelAddin.dll"'

  WriteRegStr HKLM "Software\Microsoft\Office\Excel\Addins\MyExcelAddin" "FriendlyName" "MyExcelAddin"
  WriteRegStr HKLM "Software\Microsoft\Office\Excel\Addins\MyExcelAddin" "Description" "MyExcelAddin"
  WriteRegStr HKLM "Software\Microsoft\Office\Excel\Addins\MyExcelAddin" "Manifest" "Manifest file:///$INSTDIR\MyExcelAddin.vsto|vstolocal"
  WriteRegDWORD HKLM "Software\Microsoft\Office\Excel\Addins\MyExcelAddin" "LoadBehavior" "00000003"
  WriteRegDWORD HKLM "Software\Microsoft\Office\Excel\Addins\MyExcelAddin" "CommandLineSafe" "00000000"

update 2: This actually worked eventually, I had done other things in the wrong order in the NSIS script. I hadn't copied the .dll to the folder I was attempting to register from using Regasm.exe

Evers answered 6/5, 2015 at 12:32 Comment(4)
DLLRegisterServer is the normal entry-point function export for registration, if your addin does not export it then only you would know how to register it...Hardecanute
Installshield and visual studio can both register the DLL without DLLRegisterServer implemented, surely they must be using the command line to do so.Evers
Don't know if this would be an issue, but for my Excel plugins, the "Manifest" value is just "file:///$INSTDIR/MyExcelAddin.vsto|vstolocal" as opposed to having "Manifest " on the front.August
@coolmrcroc. i am sorry but i am stuck and can't seems to fine any way to install my developed add in. can you please help me by any mean? please?Amoritta
R
0

In case you are using a 64-bit installation of Office and are sure this is appropriate to be installed for "all users", your registry paths would need to be adjusted as follows:

WriteRegStr HKLM "Software\Wow6432Node\Microsoft\Office\Excel\Addins\MyExcelAddin" "FriendlyName" "MyExcelAddin"
WriteRegStr HKLM "Software\Wow6432Node\Microsoft\Office\Excel\Addins\MyExcelAddin" "Description" "MyExcelAddin"
WriteRegStr HKLM "Software\Wow6432Node\Microsoft\Office\Excel\Addins\MyExcelAddin" "Manifest" "Manifest file:///$INSTDIR\MyExcelAddin.vsto|vstolocal"
WriteRegDWORD HKLM "Software\Wow6432Node\Microsoft\Office\Excel\Addins\MyExcelAddin" "LoadBehavior" "00000003"
WriteRegDWORD HKLM "Software\Wow6432Node\Microsoft\Office\Excel\Addins\MyExcelAddin" "CommandLineSafe" "00000000"

Otherwise, you might have better luck installing the add-in for the "current user", in which case you'd need to adjust as follows:

WriteRegStr HKCU "Software\Microsoft\Office\Excel\Addins\MyExcelAddin" "FriendlyName" "MyExcelAddin"
WriteRegStr HKCU "Software\Microsoft\Office\Excel\Addins\MyExcelAddin" "Description" "MyExcelAddin"
WriteRegStr HKCU "Software\Microsoft\Office\Excel\Addins\MyExcelAddin" "Manifest" "Manifest file:///$INSTDIR\MyExcelAddin.vsto|vstolocal"
WriteRegDWORD HKCU "Software\Microsoft\Office\Excel\Addins\MyExcelAddin" "LoadBehavior" "00000003"
WriteRegDWORD HKCU "Software\Microsoft\Office\Excel\Addins\MyExcelAddin" "CommandLineSafe" "00000000"
Rightwards answered 15/5, 2015 at 13:16 Comment(2)
even if you are installing for 32 bit excel and are on a 64 bit machine, writing the registry keys will go to Software\Wow6432Node\Microsoft automatically, using SetRegView 64 will set them to Software\Microsoft.Evers
Ah, that simplifies things such that you won't have to worry about branching your script on the detected installation. However, all my add-ons on located under HKCU, and Microsoft says that HKLM can only be used in "certain scenarios", whatever that means: msdn.microsoft.com/en-us/library/bb386106(v=vs.110).aspxRightwards

© 2022 - 2024 — McMap. All rights reserved.