View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.dotnet.languages.csharp
Dartish Dartish is offline
external usenet poster
 
Posts: 1
Default How to call functions of a DLL in Excel and in a .net project

Hi all,

Thanks in advance for the help

I have a DLL that which has several functions that I can call in Excel.
I am thinking of how to call these functions in a .net project
(authored in C#).

I guess I need to describe how I used the DLL in Excel to motive this
discussion

1. Here is the way that I can use it in Excel -- (I figured this out
with some effort)

a. If I just start Excel and type in a cell something like:
=DLLFunction(parameterList)
I know the function name and parameterList. It won't work (Excel does
not recognize the function).

b. I also opened the VB editor, from Tools -- Reference, I tried to
add the DLL, it won't work. It prompts: "Can't add a reference to the
specified file"

c. Luckily, I was provided with a template Excel file (.xls) in which
it contains two Macros [DLL_Open and DLL_Close]. I cannot edit/delete
these two Macros. I can only run these two Macros. Anyways, without
doing nothing on these two Macros, after I just opened the template
Excel file and if I type in a cell something like:
=DLLFunction(parameterList)
The function works beautifully.

d. If I open VB editor when the template Excel file is open, I can see
(in the VBA project panel) there is a project called theDLLProject,
which is presumably the "entity" that referce to the DLL in question.

=======================================

OK, here is what I am interested to do:
1. How do I call the functions in the DLL in a freshly created Excel
file? I can certainly save the template file as another file and call
the function. I am interested to know how to configure a new Excel file
to recognize this DLL

2. Is it possible that I can call the functions in this DLL in a .net
project authored in C#? I tried to add reference to this DLL in a C#
project (Project-- Add Reference), it won't work.

Thank you very much for your input.

DL