COleSafeArray
-
Whats wrong with this:
COleSafeArray arrayField; arrayField.CreateOneDim(VT\_VARIANT,6); COleSafeArray arrayValues; arrayValues.CreateOneDim(VT\_VARIANT,6); arrayField.PutElement((long \*)0, &(\_variant\_t("LastName"))); arrayValues.PutElement((long \*)0,&(\_variant\_t("Mansouri")));
Atg the PueElement statement it thrown an exception.But I can't see the error. Mazy **"If I go crazy then will you still Call me Superman If I’m alive and well, will you be There holding my hand I’ll keep you by my side with My superhuman might Kryptonite"**Kryptonite-3 Doors Down
-
Whats wrong with this:
COleSafeArray arrayField; arrayField.CreateOneDim(VT\_VARIANT,6); COleSafeArray arrayValues; arrayValues.CreateOneDim(VT\_VARIANT,6); arrayField.PutElement((long \*)0, &(\_variant\_t("LastName"))); arrayValues.PutElement((long \*)0,&(\_variant\_t("Mansouri")));
Atg the PueElement statement it thrown an exception.But I can't see the error. Mazy **"If I go crazy then will you still Call me Superman If I’m alive and well, will you be There holding my hand I’ll keep you by my side with My superhuman might Kryptonite"**Kryptonite-3 Doors Down
hi, if you use a function like this where you give in strValue your "Lastname" void FillSafeArray(CString strValue, int iRow, int iCol, COleSafeArray* sa) { VARIANT v; long index[2]; index[0] = iRow; index[1] = iCol; VariantInit(&v); v.vt = VT_BSTR; v.bstrVal = strValue.AllocSysString(); sa->PutElement(index, v.bstrVal); SysFreeString(v.bstrVal); VariantClear(&v); } hope it helps, DanielO
-
hi, if you use a function like this where you give in strValue your "Lastname" void FillSafeArray(CString strValue, int iRow, int iCol, COleSafeArray* sa) { VARIANT v; long index[2]; index[0] = iRow; index[1] = iCol; VariantInit(&v); v.vt = VT_BSTR; v.bstrVal = strValue.AllocSysString(); sa->PutElement(index, v.bstrVal); SysFreeString(v.bstrVal); VariantClear(&v); } hope it helps, DanielO
-
hi, if you use a function like this where you give in strValue your "Lastname" void FillSafeArray(CString strValue, int iRow, int iCol, COleSafeArray* sa) { VARIANT v; long index[2]; index[0] = iRow; index[1] = iCol; VariantInit(&v); v.vt = VT_BSTR; v.bstrVal = strValue.AllocSysString(); sa->PutElement(index, v.bstrVal); SysFreeString(v.bstrVal); VariantClear(&v); } hope it helps, DanielO
If i want to pass numerical value in FillSafeArray(int ivalue...)then what should i change in the FillSafeArray function? Why i need int value because when i use FillSafeArray(CString strValue..) the value saved in excel sheet as text even though that value is "number". I want the sum of column & since the values are stored in excel as text in 1 column & if sum formula is used for that column in excel automation, it gives sum as 0. Hence i thought of storing this value as int so that am able to use sum formula in excel automation. Is there any function to convert text to number in excel automation?