View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
Rob Bovey Rob Bovey is offline
external usenet poster
 
Posts: 811
Default Excel 2000 calling functions in C++

Hi Uwe,

I want to fill a range with results of my magic math. I have made the
"result range" - the place where multiple results are to be stored - part

of
the function call syntax. How do I get a series of values, stored in a C++
array in the XLL, back to the spreadsheet, into the cell range which I

have
passed to the C++ XLL.....???


A worksheet function can only modify the cell into which it has been
entered. It sounds like what you want is an array function. In that case you
need to return a type xltypeMulti with the same number of rows and columns
as your data. You would then array-enter this function into your destination
range.

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *


"um" wrote in message
...
Hello Rob,

all is fine. You were right, I had to perform major surgery on the sample,
so that VC7 would run this in Debug and Release mode. The literal string
which you can't modify, was to blame. If you'd like a copy of the modified
sample that has all that "static LPSTR" business removed, let me know and
I'll zip it up for you.

Now the next question is, the code returns one numeric value and properly
places it into the cell, where you place the formula. All good, except,

now
I want to fill a range with results of my magic math. I have made the
"result range" - the place where multiple results are to be stored - part

of
the function call syntax. How do I get a series of values, stored in a C++
array in the XLL, back to the spreadsheet, into the cell range which I

have
passed to the C++ XLL.....???

Thanks a mille,

Uwe






"Rob Bovey" wrote in message
...
Hi Uwe,

Now Excel recognizes the generic.xll when created in VC7 Debug mode. -
Release mode still doesn't work (no /ZI or /Zi switches there, and DEF

file
is properly set in linker properties) .


Not really sure what else is going on here. Are all your functions
exported as extern "C" __declspec(dllexport)?

The other thing is the handling of XL strings, i.e. in XLauto.cpp in

the
function GetXLVersion:


I think the problem here is that you're not allowed to modify a

string
litteral. VC6 let you get away with it but VC7+ doesn't.

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *


"um" wrote in message
...
Hey Rob,

who thought this was easy?

Now Excel recognizes the generic.xll when created in VC7 Debug mode. -
Release mode still doesn't work (no /ZI or /Zi switches there, and DEF

file
is properly set in linker properties) .

The other thing is the handling of XL strings, i.e. in XLauto.cpp in

the
function GetXLVersion:

--------- snipet--------
lstrcpyn(szXLVersion, xVersion.val.str + 1, *((BYTE *)

xVersion.val.str)
+
1);
szXLVersion[*((BYTE *) xVersion.val.str)] = NULL;
--------- end snipet--------

the code crashes on the 2nd line, I see nothing wrong. szXLVersion

looks
like it's properly allocated, so what's wrong with placing a

terminating
zero at the end of the string??? Very strange.. Same crash happens

(access
violation) if somewhere in the sample an XL string is created and the

first
byte of the string is set to the string's length.....

Can you help again?

Thanks a mille,

Uwe



"Rob Bovey" wrote in message
...
Hi Uwe,

<<When I compile the one from Q152152, it will only get recognized

by
Excel,
if I compile to Release of VC6.0. The Debug version does not get
recognized

Under the Project/Settings/C/C++ menu make sure that the Debug

Info
setting is Program Database and not Program Database for Edit and
Continue.
The latter setting adds tokens to the debug code that cause Excel

not
to
recognize it.

<<and either Debug or Release of VC7.0 do not get recognized

either

Same as above for the debug version, except the menu is
Project/<Project
Name Properties/C/C++/General. Also make sure that the .def file

has
been
properly associated with the project. Under the menu

Project/<Project
Name
Properties/Linker/Input the .def file should be listed in the Module
Definition File setting.

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *


"um" wrote in message
.. .
Rob,

do you have anything else in terms of samples? When I compile the

one
from
Q152152, it will only get recognized by Excel, if I compile to

Release
of
VC6.0. The Debug version does not get recognized, and either Debug

or
Release of VC7.0 do not get recognized either. Kinda hard to do,

if
you
can't use Debug code..

Thanks a mille,

Uwe