View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Bill Below[_2_] Bill Below[_2_] is offline
external usenet poster
 
Posts: 2
Default Problem passing a large safearray to Excel

I am automating Excel 2000 from a MFC program prepared in VC++2003 and
running in Win2K. Is C++ allowed here? I fill 2 COleSafeArray objects with
data and pass them to Excel as follows:

oRange.put_Value(COleVariant(saValues));
oRange.put_NumberFormat(COleVariant(saNumFormat));

For small ranges, this works fine; but when the range gets to a certain
size, say 750 rows and 8 columns, put_NumerFormat() returns an exception with
code 0x80020005. This happens for put_NumberFormat only, not for put_Value.
This does not seem to depend on the contents of saNumFormat. It can be empty
or filled compeletely with a simple format, "0", and the same thing happens.
No cells in Excel receive a number format.

If I run the same program from an XP machine with Excel 2003 installed the
problem goes away. So someday this will not be a problem. But for now I
need to support the earlier versions. Anyone know about this behavior and a
way to avoid it?

Thanks,
Bill Below