Search code examples
.netvbadlldrycode-reuse

Is there any way to resuse XLAM addin's function in another .NET project?


I have developed an XLAM addin for Excel in VBA, and I'm building another .NET project. I need to solve the same problem with completely XLAM, and I don't want to re-write this code (DRY).

Is there any way to reuse an XLAM addin's function in another .NET project?

e.g. I can compile xlam to dll and import to .NET project after that???


Solution

  • Davuz,

    A method of converting XLAM to dll does not appear to be readily available. There are ways to share functions between different applications in certain cases, e.g. writing COM functions which can be shared by both Excel and by VB.net. See this SO question and especially the comments involved for a more in-depth discussion: XLAM / XLA Addins: is there a better way?

    If you want to have add-ins that have multiple layers of functionality or which share the maximum number of functions - thereby minimizing repeat edits/writing - then I would consider this as much of an add-in design issue as much of a coding issue. This MSDN link sheds more light on designing add-ins: http://msdn.microsoft.com/en-us/library/bb384200.aspx

    So, I would argue that you should consider how you would design your add-in to work with the windows applications, and then select an approach which can be used to "bridge" conversion between the preferred applications as much as possible - such as the COM method mentioned above.

    For a more direct conversion method, then its a matter of comparing the VB functions with the .NET functions and rewriting those pieces by directly comparing them to their .NET counterparts - many of which are highly documented by microsoft. It is certainly not a perfect way to follow the principles of DRY, but it is better than starting from scratch - but I feel certain you are aware of this approach already.

    Good luck,

    ~JOL