Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Returning arrays from custom worksheet functions in xll files

Hello. I was trying to figure out how to return an array from a custom
worksheet function in an .xll file created using visual c++ 2005 express. I
haven't had a problem returning single numbers, but arrays don't seem to be
working. I want the returned array to fill a column of cells, but I can't
quite seem to figure it out. I've tried returning an XLOPER and it compiles
fine, and the add-in opens, but I get the following error when I try to use
the function:

Unhandled exception at 0x1000144c (xceltest.xll) in EXCEL.EXE: 0xC0000005:
Access violation writing location 0x00000000.

Here is the relevant portion of the code (the function table and the
function). I haven't updated the descriptions of the function in the
function table, but that shouldn't make a difference. Thanks in advance to
anyone who helps with this:

static char gszFunctionTable[NUM_FUNCTIONS][NUM_REGISTER_ARGS][MAX_LENGTH] =
{
{" AddTwo", // procedure
" RBB", // type_text
" AddTwo", // function_text
" d1, d2", // argument_text
" 1", // macro_type
" xceltest Add-In", // category
" ", // shortcut_text
" ", // help_topic
" Adds the two arguments.", // function_help
" The first number to add.", // argument_help1
" The second number to add." // argument_help2
}
};


EXPORT XLOPER WINAPI AddTwo(double d1, double d2)
{
XLOPER xlArray, xlValues[2];


xlValues[0].xltype = xltypeNum;
xlValues[1].xltype = xltypeNum;
xlValues[0].val.num = d1;
xlValues[1].val.num = d2;


xlArray.xltype = xltypeMulti;
xlArray.val.array.lparray = &xlValues[0];
xlArray.val.array.rows = 1;
xlArray.val.array.columns = 2;

return xlArray;
}



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
Adding Help Files To Custom Functions/Macros MDW Excel Programming 1 January 30th 06 05:57 PM
Linking worksheet functions and arrays - Doozie gsimmons2005 Excel Discussion (Misc queries) 1 August 17th 05 10:32 PM
RTD returning arrays Jens Thiel[_2_] Excel Programming 0 February 3rd 05 10:41 PM
Using Excel Worksheet functions in Arrays The Roon Excel Programming 1 January 13th 05 05:05 AM
Returning range object from custom functions agarwaldvk[_9_] Excel Programming 3 August 1st 04 10:46 PM


All times are GMT +1. The time now is 01:25 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"