Top  Previous  Next

This function is useful for creating VARIANTs which specify the widths of the columns in a CustomTable...


void CreateDoubleVariantArray (VARIANT& v, const double* const pValues, const UINT ikNumValues)


Some functions, like adding a custom table into a sheet, require VARIANTs which are

arrays of doubles. This function, given an array of doubles initialises the variant v.



   v.vt = VT_ARRAY | VT_R8;


   sab[0].lLbound = 0; sab[0].cElements = ikNumValues ;

   v.parray = SafeArrayCreate(VT_R8, 1, sab);


   // Fill with some values...

   for(int i=0; i<ikNumValues; i++) {

       long indices[] = {i};

       SafeArrayPutElement(v.parray, indices, (void *)&(pValues[i]));





Text, images and diagrams © 2021 Owen F. Ransen. All rights reserved. (But copy the source code as much as you want!)