![]() |
Return value from excel macro
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 |
Return value from excel macro
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. " wrote: 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 |
Return value from excel macro
On Mar 28, 1:13 am, Joel wrote:
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. " wrote: 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- Hide quoted text - - Show quoted text - It works fine. the problem is with the retval. I send 30 parameters. from val0-val28 = 29 params + function name. |
Return value from excel macro
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. " wrote: On Mar 28, 1:13 am, Joel wrote: 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. " wrote: 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- Hide quoted text - - Show quoted text - It works fine. the problem is with the retval. I send 30 parameters. from val0-val28 = 29 params + function name. |
All times are GMT +1. The time now is 05:32 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com