Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Passing a variant object to a C++ dll

Hello all,

I'm trying to send to a C++ DLL a Range object from a VB macro (that is
called from Excel).

I first achieved to copy the content of the range object into a VB
array of Double. I could get it as a double* from c++ and this work
perfectly. I however fear that all cells are not contiguous in some
cases (and I could thus get a seg.fault), and I'm also trying to use a
clean & generic way of passing VB data to C++.

I started writing this c++ function :

DLLEXPORT void CALLCONVENTION get_variant( VARIANT* variant )
{
switch(variant-vt){
case VT_DISPATCH:
IDispatch *something = variant-pdispVal;
break;
//... other cases follow

}

My question is: how may I have information on the object type that is
pointed by "something". May I get the list of member functions of
"something".

I expect to get a VT_ARRAY (i.e. SAFEARRAY?) and then use the
SafeArrayGetElement function...

Thanks in advance for your help!

Martin

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Passing a variant object to a C++ dll


The best way to pass a Range to a C++ DLL is through the Excel C API.
This api has been upgraded along with Excel since the 95 verstion. The
main object is a union, called an XLOPER.

You can use RapidXLL to build this interface automatically (the process
then becomes a one-liner). RapidXLL will automatically interface your
native C / C++ to both Excel and the .NET framework. Please visit
http://www.RapidXLL.net for free samples.

Sincerely,

The RapidXLL Team


Martin wrote:
Hello all,

I'm trying to send to a C++ DLL a Range object from a VB macro (that is
called from Excel).

I first achieved to copy the content of the range object into a VB
array of Double. I could get it as a double* from c++ and this work
perfectly. I however fear that all cells are not contiguous in some
cases (and I could thus get a seg.fault), and I'm also trying to use a
clean & generic way of passing VB data to C++.

I started writing this c++ function :

DLLEXPORT void CALLCONVENTION get_variant( VARIANT* variant )
{
switch(variant-vt){
case VT_DISPATCH:
IDispatch *something = variant-pdispVal;
break;
//... other cases follow

}

My question is: how may I have information on the object type that is
pointed by "something". May I get the list of member functions of
"something".

I expect to get a VT_ARRAY (i.e. SAFEARRAY?) and then use the
SafeArrayGetElement function...

Thanks in advance for your help!

Martin


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
is a variant an object James Cornthwaite Excel Programming 4 June 9th 06 11:49 PM
Passing value of variant Andrew Excel Programming 3 May 22nd 06 03:16 AM
Passing variant arrays to C/C++ dll's agarwaldvk[_35_] Excel Programming 0 October 18th 04 01:33 AM
IsArray on Variant/Object/Range returns true?? QuantDev Excel Programming 10 July 28th 04 02:51 PM
Argument can be a variant or an object onedaywhen Excel Programming 1 September 25th 03 04:20 PM


All times are GMT +1. The time now is 02:00 PM.

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

About Us

"It's about Microsoft Excel"