fumito
fumito

Reputation: 324

How to wrap an Excel Rnage object passed in VARIANT in Excel::Range

I'm writing a c++ function that receives Excel Range passed as an argument of LPVARIANT type.

In that function I want to use Excel::Range class created by #import to manipulate the Range for convenience. How can I wrap the object passed as VARIANT in Excel::Range?

All the samples on the web seem to assume range objects are retrieved from parent objects, which are already Excel:: classes.

Upvotes: 1

Views: 318

Answers (1)

avo
avo

Reputation: 10731

Something like this:

VARIANT* pArg = NULL;

// Call Excell to get pArg
//...

// Get Excel::Range from VARIANT 
Excel::RangePtr range;
if (V_VT(pArg) == VT_DISPATCH || V_VT(pArg) == VT_UNKNOWN))
  V_UNKNOWN(pArg)->QueryInterface(&range);

Upvotes: 1

Related Questions