Hi Ray
Your third Excel4 argument should be the number of arguments that follow, so
6 in your example.
Your 8th Excel4 argument should be a comma-delimited string of your argument
names, so given the type string, there's one missing, so you need
"Param1,Param2"
Your 9th Excel4 argument should be a pointer to an integer xloper (not the
xloper itself).
So
iOutput = Excel4(
xlfRegister, //1
0, //2
6, //3
(LPXLOPER)&xModuleText, //4
(LPXLOPER)XlfOper("VLookup"), //5
(LPXLOPER)XlfOper("PPP#"), //6
(LPXLOPER)XlfOper("VLookup"), //7
(LPXLOPER)XlfOper("Param1,Param2"), //8
&xInt); //9
I think this might solve your problems
Regards
Steve Dalton
> Can someone please post n example of a call to Excel4 that registers
> a class 2 Excel function a la VLookup? I am getting consistent
[quoted text clipped - 22 lines]
> (LPXLOPER)XlfOper("Param"), //8
> xInt); //9
rtrivgreg@yahoo.com - 26 Jan 2006 17:21 GMT
That worked Steve, thanks a lot. Now I have a related issue..
When I attempt to run the internal Excel API xlfVlookup, Excel4 is
returning int 8
//#define xlretInvXloper 8 /*! invalid OPER structure */
Is it necessary for me to register xlfVlookup as a class-2 function? I
suspect not. I am checking the LOPER data types for
XlfOper xllookupVal, XlfOper xltableName, XlfOper xltableColumn
And they all appear to be correct (num,sref and 1)
Again, thanks for your advice.
Kind Regards,
Ray Gregoire
LPXLOPER EXCEL_EXPORT xVLookupExact(XlfOper xllookupVal, XlfOper
xltableName, XlfOper xltableColumn)
{
EXCEL_BEGIN;
WORD wType;
LPXLOPER tempLPXLOPER;
tempLPXLOPER = xllookupVal.GetLPXLOPER();
wType = tempLPXLOPER->xltype;
std::string ret1 = GetParameterData(wType);
tempLPXLOPER = xltableName.GetLPXLOPER();
wType = tempLPXLOPER->xltype;
std::string ret2 = GetParameterData(wType);
tempLPXLOPER = xltableColumn.GetLPXLOPER();
wType = tempLPXLOPER->xltype;
std::string ret3 = GetParameterData(wType);
int iReturn = Excel4(xlfVlookup,(LPXLOPER)&xLookupResults, 3,
(LPXLOPER)&xllookupVal, (LPXLOPER)&xltableName,
(LPXLOPER)&xltableColumn);
return Lookup(xllookupVal, xltableName, xltableColumn, true, true);
EXCEL_END;
}
> Hi Ray
>
[quoted text clipped - 52 lines]
> > (LPXLOPER)XlfOper("Param"), //8
> > xInt); //9
Steve Dalton - 28 Jan 2006 18:05 GMT
Hi Ray
Assuming XlfOper is essentially the XLOPER structure extended with some
accessor functions (which is I think what the XLW wrapper does), then your
exported function should be declared as taking pointers to these, not actual
instances. Excel will be passing you 8-byte pointers if you have registered
your function as taking either R or P types, which your code is interpreting
as 10-byte xlopers!
Does that fix it?
Regards
Steve
> That worked Steve, thanks a lot. Now I have a related issue..
>
[quoted text clipped - 104 lines]
>> > (LPXLOPER)XlfOper("Param"), //8
>> > xInt); //9
rtrivgreg@yahoo.com - 31 Jan 2006 20:50 GMT