I am using the Instruments ExcelReport and the MicroSoft Excel 9.0 Library and I am trying to write a string to a single cell in a spreadsheet. I am able to open Excel and get the appropriate handles, I can write numeric data but not text. Here is the code segment...
int Write1StringExcel (char *CellRange, char *WriteStr)
//This will write a single double to an excel spreadsheet
{
int failure=-99;
char errorBuf[256];
BSTR arg1__AutoType=0;
failure=CA_CStringToBSTR (WriteStr, &arg1__AutoType);
CA_GetAutomationErrorString (failure, errorBuf, sizeof (errorBuf));
// Write the value of the Single Cell Range
failure = ExcelRpt_WriteData (ExcelWorksheetHandle, CellRange, ExRConst_dataString, 1, 1, arg1__AutoType);
CA_GetAutomationErrorString (failure, errorBuf, sizeof (errorBuf));
return (failure);
}
I discovered that just sending a char * in ExcelRpt_WriteData caused a general protection fault, so I tried creating a BSTR. The function call works now but writes garbage. I believe my problem is in the CA_CStringToBSTR call. When I view the variable arg1 there is "No Size Information". I cannot seem to find a method to set the size information of the BSTR. Does anybody have any advice on how to either make the charachter pointer work or the Basic String work for the call to ExcelRpt_WriteData?
Thanks,
-don
Go Cubbies!!