Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Excel
123quattro
charting
crashesgpfs
datamap
excel
interopoledde
links
misc
newusers
printing
programming
querydao
sdk
setup
templates
worksheet.functions
  
 
date: Thu, 26 Jun 2008 10:16:02 -0700,    group: microsoft.public.excel.sdk        back       


Re: Excel4(xlfGetWorkspace, &version, 1, & arg) - Excel2007   
Hi, 

I am trying to retrieve the excel version by using a similar method
(the code come from XLW wrapper, indead I got the same bug with the code
in Steve Dalton book's):

    XLOPER xRet1, xRet2, xTemp1, xTemp2;
    xTemp1.xltype = xTemp2.xltype = xltypeInt;
    xTemp1.val.w = 2;
    xTemp2.val.w = xltypeInt;
    int res1 =Excel4_(xlfGetWorkspace, &xRet1, 1, &xTemp1);
    int res2 = Excel4_(xlCoerce, &xRet2, 2, &xRet1, &xTemp2);
    Excel4_(xlFree, 0, 1, &xRet1);
    gVersion = xRet2.val.w;

with EXCEL2003 this work fine but with excel 2007 the value res2 returned by 
Excel4_(xlCoerce...) as a value 32 (whereas res1 = 0). The string in xRet2 
seems
OK (except it is not a null terminated string). Even if I add zero after the 
last version byte in the string my call to xlCoerce fails.

It seems to be a bug in excel 2007 C API. 

Does anyone have a solution?

Martial.



"Aggie" wrote:

> I have found the solution, thanks so much for your help Steve !
> 
> Happy New Year !
> 
> Aggie
> 
> 
> 
> "Steve Dalton" wrote:
> 
> > Hi Aggie
> > 
> > The advice to call this from xlAutoOpen is just that - advice.  The reason 
> > is that you probably need to set a global version variable up early in that 
> > add-in's session, before you are calling other things.  If you are getting 
> > an exception, then I suspect you are calling the function at a time where 
> > the C API is not availalbe, for example from DllMain.  Is that the case?
> > 
> > Have you checked that your project has the xlcall.lib installed and 
> > building/linking correctly?  Are you able to call any other functions using 
> > Excel4(...)?
> > 
> > How have you initialised your xloper arg?  You should have something like 
> > this:
> > 
> > xloper arg;
> > arg.xltype = xltypeNum;
> > arg.val.num = 2.0;
> > 
> > or this:
> > 
> > xloper arg;
> > arg.xltype = xltypeInt;
> > arg.val.w = 2;
> > 
> > You can call this function as often as you like.
> > 
> > Regards
> > 
> > Steve Dalton
> > 
> > "Aggie"  wrote in message 
> > news:7E4BCD11-E62A-4084-99BA-37C2E78E6D02@microsoft.com...
> > > Hello
> > >
> > > I have read this:
> > >
> > > Getting the Running Version
> > > You should detect which version is running using Excel4(xlfGetWorkspace,
> > > &version, 1, & arg), where arg is a numeric XLOPER set to 2 and version is 
> > > a
> > > string XLOPER which can then be coerced to an integer. For Excel 2007, 
> > > this
> > > is 12. You should do this in, or from, xlAutoOpen. You can also call
> > > XLCallVer, but this does not indicate which of the pre-2007 versions you 
> > > are
> > > running.
> > >
> > > from:
> > > http://msdn2.microsoft.com/en-us/library/aa730920.aspx#office2007excelXLL_WritingCrossversionXLLs
> > >
> > > In my code, I'm using Excel4(xlfGetWorkspace, &version, 1, & arg)  to find
> > > out the Excel's version ... but this call is not located in xlAutoOpen and
> > > I'm getting an exception .... Should I move my call to Excel4 to 
> > > xlAutoOpen?
> > > How many times can I use Excel4(xlfGetWorkspace, &version, 1, & arg) in my
> > > code? just once?
> > >
> > > Thanks !
> > >
> > > Aggie 
> > 
> > 
> >
date: Thu, 26 Jun 2008 10:16:02 -0700   author:   Martial.

Re: Excel4(xlfGetWorkspace, &version, 1, & arg) - Excel2007   
In fact the bug is that Excel use a coma as decimal separator (french 
setting) but in the string returned to indicate the version the decimal 
separator is a dot and excel badly manage conversion.

"Martial." wrote:

> Hi, 
> 
> I am trying to retrieve the excel version by using a similar method
> (the code come from XLW wrapper, indead I got the same bug with the code
> in Steve Dalton book's):
> 
>     XLOPER xRet1, xRet2, xTemp1, xTemp2;
>     xTemp1.xltype = xTemp2.xltype = xltypeInt;
>     xTemp1.val.w = 2;
>     xTemp2.val.w = xltypeInt;
>     int res1 =Excel4_(xlfGetWorkspace, &xRet1, 1, &xTemp1);
>     int res2 = Excel4_(xlCoerce, &xRet2, 2, &xRet1, &xTemp2);
>     Excel4_(xlFree, 0, 1, &xRet1);
>     gVersion = xRet2.val.w;
> 
> with EXCEL2003 this work fine but with excel 2007 the value res2 returned by 
> Excel4_(xlCoerce...) as a value 32 (whereas res1 = 0). The string in xRet2 
> seems
> OK (except it is not a null terminated string). Even if I add zero after the 
> last version byte in the string my call to xlCoerce fails.
> 
> It seems to be a bug in excel 2007 C API. 
> 
> Does anyone have a solution?
> 
> Martial.
> 
> 
> 
> "Aggie" wrote:
> 
> > I have found the solution, thanks so much for your help Steve !
> > 
> > Happy New Year !
> > 
> > Aggie
> > 
> > 
> > 
> > "Steve Dalton" wrote:
> > 
> > > Hi Aggie
> > > 
> > > The advice to call this from xlAutoOpen is just that - advice.  The reason 
> > > is that you probably need to set a global version variable up early in that 
> > > add-in's session, before you are calling other things.  If you are getting 
> > > an exception, then I suspect you are calling the function at a time where 
> > > the C API is not availalbe, for example from DllMain.  Is that the case?
> > > 
> > > Have you checked that your project has the xlcall.lib installed and 
> > > building/linking correctly?  Are you able to call any other functions using 
> > > Excel4(...)?
> > > 
> > > How have you initialised your xloper arg?  You should have something like 
> > > this:
> > > 
> > > xloper arg;
> > > arg.xltype = xltypeNum;
> > > arg.val.num = 2.0;
> > > 
> > > or this:
> > > 
> > > xloper arg;
> > > arg.xltype = xltypeInt;
> > > arg.val.w = 2;
> > > 
> > > You can call this function as often as you like.
> > > 
> > > Regards
> > > 
> > > Steve Dalton
> > > 
> > > "Aggie"  wrote in message 
> > > news:7E4BCD11-E62A-4084-99BA-37C2E78E6D02@microsoft.com...
> > > > Hello
> > > >
> > > > I have read this:
> > > >
> > > > Getting the Running Version
> > > > You should detect which version is running using Excel4(xlfGetWorkspace,
> > > > &version, 1, & arg), where arg is a numeric XLOPER set to 2 and version is 
> > > > a
> > > > string XLOPER which can then be coerced to an integer. For Excel 2007, 
> > > > this
> > > > is 12. You should do this in, or from, xlAutoOpen. You can also call
> > > > XLCallVer, but this does not indicate which of the pre-2007 versions you 
> > > > are
> > > > running.
> > > >
> > > > from:
> > > > http://msdn2.microsoft.com/en-us/library/aa730920.aspx#office2007excelXLL_WritingCrossversionXLLs
> > > >
> > > > In my code, I'm using Excel4(xlfGetWorkspace, &version, 1, & arg)  to find
> > > > out the Excel's version ... but this call is not located in xlAutoOpen and
> > > > I'm getting an exception .... Should I move my call to Excel4 to 
> > > > xlAutoOpen?
> > > > How many times can I use Excel4(xlfGetWorkspace, &version, 1, & arg) in my
> > > > code? just once?
> > > >
> > > > Thanks !
> > > >
> > > > Aggie 
> > > 
> > > 
> > >
date: Fri, 27 Jun 2008 02:28:00 -0700   author:   Martial.

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us