Return value from excel macro

E

Eran.Yasso

Hi All,

I have application in C# which I call excel MACRO. All works fine. the
point is that i want to return value(even simple - 0\1). I saw some
samples in vb but it doesn't work in C#.

This is what I do:

Excel
Public Function te() As Long
te = 1
End Function

C#
int k = ( int )oXL.Run( function_name , val0,val1...val28);

in this case, i get exeption in C#.

thanks for the help
 
G

Guest

The number of parameters have to match between the C# call and the excel macro.

The function can havve more parameters than the calling statement, but not
the opposite. You are probabbly getting a stack exception. Your caling
functrion has 28 parameters.
 
E

Eran.Yasso

The number of parameters have to match between the C# call and the excel macro.

The function can havve more parameters than the calling statement, but not
the opposite. You are probabbly getting a stack exception. Your caling
functrion has 28 parameters.











- Show quoted text -

It works fine. the problem is with the retval. I send 30 parameters.
from val0-val28 = 29 params + function name.
 
G

Guest

Passing parameters and return values arre pushes and pops off of a memory
stack. the compiler uses the number of parameters to determine the number of
memory locations that are needed. If you send more parameters than the
function uses your return value will get screwed up. You also have tto mnake
sure each parameter type is consitant between the calling routine and and
the routine.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top