Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Reading a Cell Value in C++ (with Autowrap)

Problem solved, this does work:

char* myout;
char* myout2;
float fOut;

{
VARIANT rVal;
VariantInit(&rVal);
my_manager-AutoWrap(DISPATCH_PROPERTYGET|DISPATCH_METHOD, &rVal,
pXlRange, L"value", 0);

switch (rVal.vt)
{
case VT_I2:
myout="VT_I2";
break;
case VT_I4:
myout="VT_I4";
break;
case VT_R4:
myout="VT_R4";
break;
case VT_R8:
myout="VT_R8";
fOut=rVal.dblVal;
break;
case VT_BSTR:
myout="VT_BSTR";
{
USES_CONVERSION;
myout2=W2A(rVal.bstrVal);
}
break;
default:
myout="Field type not supported.";
break;
}
VariantClear(&rVal);
}

Christian Friedrich schreef:

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?


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Autowrap in a cell forest8 Excel Discussion (Misc queries) 7 September 9th 09 03:55 PM
Error Message: NULL IDispatch passed to Autowrap() Aviral Sharma Excel Discussion (Misc queries) 0 March 13th 09 05:13 AM
Reading a cell in VBA Ruatha New Users to Excel 3 June 11th 06 04:01 PM
Reading last cell jackh7777777 Excel Discussion (Misc queries) 2 May 26th 06 01:28 AM
Cell Reading Problem Shashi Bhosale Excel Programming 2 July 22nd 04 01:37 PM


All times are GMT +1. The time now is 10:37 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"