Automation - any size limitations of VARIANT

  • Follow


I want to use Automation to send a fairly large XML string to an Excel 
Macro using

VARIANT  _Application::Run(const VARIANT& Macro, const VARIANT& Arg1, 
const VARIANT& Arg2,....const VARIANT& Arg30);

I would like to send up to 2 to 3mb as an XML string - does anyone know 
if this will be OK - before I spend too much time trying to implement it

Many thanks for any replies
0
Reply phil 2/28/2010 3:08:39 PM

"phil oakleaf" <news@oakleafsoftware.co.uk> ha scritto nel messaggio 
news:#oAk7fIuKHA.5384@TK2MSFTNGP04.phx.gbl...

> I want to use Automation to send a fairly large XML string to an Excel 
> Macro using
>
> VARIANT  _Application::Run(const VARIANT& Macro, const VARIANT& Arg1, 
> const VARIANT& Arg2,....const VARIANT& Arg30);
>
> I would like to send up to 2 to 3mb as an XML string - does anyone know if 
> this will be OK - before I spend too much time trying to implement it

I think that OLE Automation uses BSTR type to pass strings.
Those BSTR types are Unicode (wchar_t) length-prexifed strings.

It seems that the length field is four bytes:

http://msdn.microsoft.com/en-us/library/ms221069.aspx

Moreover, the SysAllocStringLen API

http://msdn.microsoft.com/en-us/library/ms221639.aspx

has a parameter 'cch' which is an 'unsigned int', so its max value should be 
2^32-1 in 32-bit systems.
So 2-3 MB for a BSTR should be just fine.

Giovanni

 

0
Reply Giovanni 2/28/2010 3:56:12 PM


Giovanni Dicanio wrote:
> "phil oakleaf" <news@oakleafsoftware.co.uk> ha scritto nel messaggio 
> news:#oAk7fIuKHA.5384@TK2MSFTNGP04.phx.gbl...
> 
>> I want to use Automation to send a fairly large XML string to an Excel 
>> Macro using
>>
>> VARIANT  _Application::Run(const VARIANT& Macro, const VARIANT& Arg1, 
>> const VARIANT& Arg2,....const VARIANT& Arg30);
>>
>> I would like to send up to 2 to 3mb as an XML string - does anyone 
>> know if this will be OK - before I spend too much time trying to 
>> implement it
> 
> I think that OLE Automation uses BSTR type to pass strings.
> Those BSTR types are Unicode (wchar_t) length-prexifed strings.
> 
> It seems that the length field is four bytes:
> 
> http://msdn.microsoft.com/en-us/library/ms221069.aspx
> 
> Moreover, the SysAllocStringLen API
> 
> http://msdn.microsoft.com/en-us/library/ms221639.aspx
> 
> has a parameter 'cch' which is an 'unsigned int', so its max value 
> should be 2^32-1 in 32-bit systems.
> So 2-3 MB for a BSTR should be just fine.
> 
> Giovanni
> 
> 
> 
Thanks for the info - I'll try it out with something much bigger and see 
what happens

Phil
0
Reply phil 2/28/2010 5:40:31 PM

Just tested it with an 8mb string and it worked fine

I should have tried this rather than being lazy and asking for help

Phil

0
Reply phil 3/1/2010 8:30:27 AM

"phil oakleaf" <news@oakleafsoftware.co.uk> wrote in message 
news:eB47zlRuKHA.6124@TK2MSFTNGP04.phx.gbl...
>
> Just tested it with an 8mb string and it worked fine
>
> I should have tried this rather than being lazy and asking for help

Look at it this way, now there is a record that will show up in a google 
search for anyone else with the same question! You weren't lazy, you 
performed a valuable service! ;-)

-Pete 


0
Reply Pete 3/1/2010 7:14:36 PM

4 Replies
313 Views

(page loaded in 0.05 seconds)

Similiar Articles:
















7/25/2012 10:14:57 PM


Reply: