View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Christian Friedrich Christian Friedrich is offline
external usenet poster
 
Posts: 3
Default Reading a Cell Value in C++ (with Autowrap)

Hi there,

i can't read a cell value in excel.

writing a cell value works fine with this:
int cell_value=12345;
{
VARIANT val;
val.vt = VT_I4;
val.lVal = cell_value;
my_manager-AutoWrap(DISPATCH_PROPERTYPUT, NULL, pXlRange, L"Value",
1, val);
}

but when i change the code to reading a cell value, it does not work:

VARIANT k;
k.vt= VT_BSTR;
{
VARIANT rVal;
VariantInit(&rVal);
my_manager-AutoWrap(DISPATCH_PROPERTYGET|DISPATCH_METHOD, &rVal,
pXlRange, L"value", 0);
VariantCopy(&k, &rVal);
VariantClear(&rVal);
}
BSTR mybstr=k.bstrVal;
USES_CONVERSION;
char* myout = W2A(mybstr);
VariantClear(&k);

what's wrong?