Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / January 2006

Tip: Looking for answers? Try searching our database.

excel4() exception when attempting to register class 2 function

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
rtrivgreg@yahoo.com - 25 Jan 2006 18:02 GMT
  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
exceptions when I attempt to do this.

Kind Regards,

Ray Gregoire

XLOPER xModuleText;
    int iOutput = Excel4(xlGetName,&xModuleText,0);

    XLOPER xInt;

    xInt.xltype = xltypeInt;
    xInt.val.w = 1;

    iOutput = Excel4(
    xlfRegister, //1
    0, //2
    8, //3
    (LPXLOPER)&xModuleText, //4
    (LPXLOPER)XlfOper("VLookup"), //5
    (LPXLOPER)XlfOper("PPP#"), //6
    (LPXLOPER)XlfOper("VLookup"), //7
    (LPXLOPER)XlfOper("Param"), //8
    xInt); //9
Steve Dalton - 25 Jan 2006 21:43 GMT
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
that fixed it!
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.