convert selection variant idispatch to something useful
I have no idea how to convert the variant to char * strings:
Figured it out:
{
VARIANT result;
VariantInit ( & result);
OLEMethod (DISPATCH_PROPERTYGET, & result, pXlApplication, L"Selection", 0);
if (result.vt == VT_DISPATCH)
{
IDispatch *pDisp = result.pdispVal;
// this will get the contents of the selected cell
// VariantInit ( & result);
// OLEMethod (DISPATCH_PROPERTYGET, & result, pDisp, L"Value", 0);
// int res_value = result.vt;
// this will get the address of the selected cell
VariantInit ( & result);
OLEMethod (DISPATCH_PROPERTYGET, & result, pDisp, L"Address", 0);
if (result.vt == VT_BSTR)
selection = _bstr_t (result.bstrVal);
pDisp - Release ();
}
}
Thanks,
Lynn
|