Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Adding Help Files To Custom Functions/Macros | Excel Programming | |||
Linking worksheet functions and arrays - Doozie | Excel Discussion (Misc queries) | |||
RTD returning arrays | Excel Programming | |||
Using Excel Worksheet functions in Arrays | Excel Programming | |||
Returning range object from custom functions | Excel Programming |