Reputation: 139
How can I use my C# project within Excel (VBA) when it is in executable form?
In Visual Studio, if I go to my project settings and change the "Output Type" to "Class Library", then I can successfully add a reference to my project in Excel VBA (by browsing to the DLL in the references section).
However, when my "Output Type" is set to "Windows Application", if I attempt to add a reference (within Excel VBA) to the newly generated EXE file, I receive the following error:
Can't add a reference to the specified file
How can I reference my .NET EXE within Excel VBA?
(My purpose for using an exe rather than a DLL is so that my application can be used both as a Windows Application and as a COM object)
Upvotes: 0
Views: 583
Reputation: 56697
Without knowing the exact details I simply guess that a DLL exports functions that are required by Excel. An EXE usually does not export any functions.
The good thing about .NET is that you can easily create modular application. So why not put the core functionality into a DLL and create an application that can use the functionality?
That way you could use the DLL from VBA and still have an application you can use standalone.
Upvotes: 2