PDA

View Full Version : How to call .Net DLLs in Excel?



sankartalam
09-16-2008, 08:12 AM
Hi all,
I have DLL files which are having some logic related to Macros. I have created those DLLs by using Visual Studios. I want to use those DLLs files and I will perform some operations in macros.
Could anyone help me please.

Bob Phillips
09-16-2008, 08:16 AM
Can't say I have done it myself, but DLLs are DLLs are DLLs, so set a reference in the VBIDE to it, and you should be able to call any of its methods.

Kenneth Hobs
09-16-2008, 09:34 AM
Depends on the DLL structure I suppose. Do what xld said after you have installed it using RegSvr32.

sankartalam
09-16-2008, 09:56 AM
Could you please let me know how to call the sub routines in DLLs.

Suppose i have created one class module in the .Net with some sub routines in that class module and prepared class library file. & I have added that dll into my Excel. Could you please give sample code to call the sub routine in that DLL.

Kenneth Hobs
09-16-2008, 10:07 AM
You first have to register it as I detailed earlier. You can add the reference as xld detailed to use object.method.properties as any refence provided you set up the DLL properly. Another method is to use API methods but it depends on your functions and if you set them up as the standard Windows DLL's like user32.dll and such.

Attach it if you like or post to a free shared site like 4shared.com, box.net or mediafire.com and we will look at it.