Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default 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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default 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.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to check data from excel list against access query and return value back to excel dreamkeeper Excel Worksheet Functions 0 October 31st 07 07:26 PM
Set up a macro in one row and then return to fill in next row? Mallers Excel Programming 1 April 18th 06 03:02 PM
put value into cell after return from macro AltshulerMG Excel Programming 8 September 16th 05 06:46 PM
run macro on return kizzie Excel Discussion (Misc queries) 1 August 10th 05 04:33 PM
I want to run a macro when i press return Concrete Hippo Excel Programming 2 August 3rd 05 09:21 AM


All times are GMT +1. The time now is 06:30 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"