Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Problem passing a large safearray to Excel

Hi Bill,

If you find 682 x 8 works but one more row fails it's probably due to the
5462 max element limit that hits many things with arrays in xl97 & xl2000.

Perhaps something like -
if xlVer < 10 then
do multiple arrays under 5462 elements
else: normal way

Regards,
Peter T

"Bill Below" wrote in message
...
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Problem passing a large safearray to Excel

Thanks, Peter. That was it. The KB to read is 177991 if anyone want to
follow up.

Bill

"Peter T" wrote:

Hi Bill,

If you find 682 x 8 works but one more row fails it's probably due to the
5462 max element limit that hits many things with arrays in xl97 & xl2000.

Perhaps something like -
if xlVer < 10 then
do multiple arrays under 5462 elements
else: normal way

Regards,
Peter T

"Bill Below" wrote in message
...
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




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Retrieve Excel Cell Range into SAFEARRAY (VC++) Henry[_7_] Excel Programming 6 August 3rd 05 11:33 AM
Passing large number of variables to function RB Smissaert Excel Programming 5 July 31st 05 11:09 PM
SAFEARRAY [in] and [out] MB Blackburn Excel Programming 0 May 12th 05 10:08 PM
Excel VBA - Problem calculating and passing values to another worksheet DanielCox Excel Programming 1 August 31st 04 12:36 PM
Fill a Range with VB SafeArray Rob[_17_] Excel Programming 3 April 9th 04 09:41 AM


All times are GMT +1. The time now is 08:49 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"