I'm currently developing an Excel Add-In using the Excel-DNA library. Sadly I need to serialize the Add-In somehow into the workbook so if the workbook is opened, the Add-In's code may be executed.
Before, I worked with VBA and Excel macros which've been run greatly, I could serialize the macro and upload the workbook. A software put data into it and delivered the edited workbook and I just had to open the workbook for the macro to execute.
I tried that with an Add-In (eg loading the Add-In and saving the workbook) but that didn't work, the Add-In seems to be not saved at all. Is there any other chance in serializing the Add-In into a workbook so people who just got the workbook can execute the Add-In's code?
You can include code in the Excel workbook that will install the add-in if it isn't already. You could also have it uninstall the add-in on close if you only want the add-in installed while the workbook is open.
Check out JKP's Name Manager, specifically the code in the Setup Name Manager file.
http://www.jkp-ads.com/OfficeMarketPlaceNM-EN.asp
It finds the add-in, which is assumed to be in the same path and as the Setup file, and copies it to the UserLibrary, which is the default path for add-ins. Then it sets the Addin.Installed property to True.
JKP's addin is and native Excel add-in, not an Excel DNA one, so there may be some differences (and I don't know what they are). But you may have to deal with Application.COMAddins rather than Application.Addins.
The way I understand Add-Ins, they sit separately in a way they can't be bound together with a workbook. The way I have understood them (and used them up to this point) is, for lack of a better term, a weird 'mini-program' that sits loaded inside Excel itself, not inside your workbook - you install it, it has access to more PC resources, Add-Ins even land in the list of programs for Windows, unlike a VBA macro.
Add-Ins solve a lot of problems, but do create a new one in the process. Even if you built a process that reached out on launch for the addin to install, I think it would still require a restart of Excel to be accessible from within the application, which would be frustrating. Add-In deployment is still fairly clunky, in my opinion.
Where I work we have a deployment process to deliver a Start Menu entry that will open excel and the correct version of the xll.
I have never heard of people embedding the addin in the workbook. But you can do the opposite, your addin can be coupled with a XLA or you can create an Addin menu with entries for the user to open a specific version of the workbook. This tie the workbook to a specific version of the addin rather than the opposite like you asked but it may be useful for your purposes. Uou could use a network drive for a basic implementation.
This would achieve kind of the same result by inverting your logic. However this is a costly solution in terms of manpower to create this infrastructure.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.