Passing a variant object to a C++ dll

M

Martin

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
 
W

webmaster

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top