View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Lynn McGuire[_2_] Lynn McGuire[_2_] is offline
external usenet poster
 
Posts: 47
Default 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