Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA COUNTA function and C++ automation
using the VB TO VC Automation Code Converter (B2CSE utility from Microsoft),
this call to AutoWrap AutoWrap(DISPATCH_METHOD, &rVal, wkbs1.pdispVal, L"CountA", 1, parm); sometimes correctly returns the number of non blank values in a range, and other times it seems to miss values which are in the range, returning 0, instead of the number of columns. Any ideas? for(int r=1;r<=initialrow;r++) { string thecol=""; int acol=25; thecol=ColumnLetter(acol); string newrow=""; newrow="A"+biaUtils::extractInt(r)+":"+thecol+biaU tils::extractInt(r); VARIANT testRange = {0}; VARIANT parm; VARIANT wkbs; AutoWrap(DISPATCH_PROPERTYGET|DISPATCH_METHOD, &wkbs, pWorkbook, L"activesheet", 0); parm.vt = VT_BSTR; VARIANT url; url.vt = VT_BSTR; int nLen = newrow.size() + 1; LPWSTR w_filename = new WCHAR [nLen]; mbstowcs(w_filename, newrow.c_str(), nLen); parm.bstrVal = ::SysAllocString(w_filename); VARIANT rVal = {0}; // Temporary result holder VARIANT rVal1 = {0}; // Temporary result holder AutoWrap(DISPATCH_PROPERTYGET|DISPATCH_METHOD, &rVal, wkbs.pdispVal, L"range", 1, parm); VariantClear(&parm); VariantCopy(&testRange, &rVal); VariantClear(&rVal); //VariantClear(&wkbs); //int rownumber,int endcol //for(int r=initialrow;r=1;--r){ VARIANT RangeIsEmpty = {0}; VARIANT RangeIsBlank = {0}; VARIANT wkbs1 ={0}; AutoWrap(DISPATCH_PROPERTYGET|DISPATCH_METHOD, &wkbs1, m_pDispApp , L"WorksheetFunction", 0); VariantCopy(&parm, &testRange); //AutoWrap(DISPATCH_PROPERTYGET|DISPATCH_METHOD, &rVal, wkbs1.pdispVal, L"CountA", 1, parm); AutoWrap(DISPATCH_METHOD, &rVal, wkbs1.pdispVal, L"CountA", 1, parm); //AutoWrap(DISPATCH_METHOD, &rVal, wkbs1.pdispVal, L"CountIF", 2,_variant_t(""),parm); AutoWrap(DISPATCH_PROPERTYGET|DISPATCH_METHOD, &rVal1, wkbs1.pdispVal, L"CountBlank", 1, parm); //AutoWrap(DISPATCH_METHOD, &rVal1, wkbs1.pdispVal, L"CountBlank", 1, parm); if(r<230){ int u=10; } VariantClear(&parm); VariantCopy(&RangeIsEmpty, &rVal); VariantCopy(&RangeIsBlank, &rVal1); //int ww=RangeIsEmpty.dblVal; //if (RangeIsEmpty.dblVal0){ //if (RangeIsEmpty.dblVal< actual_column ){ if (RangeIsEmpty.dblVal< acol ){ VariantClear(&rVal); newrcorner="$A$1:$"; newrcorner+=thecol; newrcorner+="$"+biaUtils::extractInt(r); #ifdef _DEBUG biaLogger::global().debug("LastCell: " + newrcorner); #endif int actual_row=r; //foundcorner=1; break; } VariantClear(&rVal); VariantClear(&rVal1); //} //if(foundcorner){ //foundcorner=0; //break; //} } |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
COUNTA Function | Excel Worksheet Functions | |||
COUNTA Function | Excel Worksheet Functions | |||
Counta function | Excel Worksheet Functions | |||
Using the COUNTA function | Excel Discussion (Misc queries) | |||
COUNTA Function not working =COUNTA(C3:C69,"NH") | Excel Worksheet Functions |