LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

ExcelRpt_WorkbookSave

Hello,
I has a functionExcelSaveFile, the function should save the woorkbook.
but still an error comes back, which say handle not exist
can somebody help me perhaps?
 

 
 
EXCEL ExcelSaveFile( EXCEL XLSFILE, char *FILENAME )
{
        HRESULT error;
        char buffer[ MAX_PATHNAME_LEN ];
       
        //save the file
        if( error = ExcelRpt_WorkbookSave( XLSFILE.WORKBOOK, FILENAME, ExRConst_DefaultFileFormat) )
        {
                CA_GetAutomationErrorString( error, buffer, MAX_PATHNAME_LEN );
                MessagePopup( "ExcelSaveFile", buffer );       
        };
       
        return( XLSFILE );
}
 
0 Kudos
Message 1 of 2
(3,629 Views)

Hi Axinia,

you need to create a valid Excel workbook handle that refers to a unique spreadsheet.

 

I recommend you take a look at the Excel examples that are shipped with CVI  (Help->Find Examples, search for "Excel").

 

Here, the handles are created as follows: 

static CAObjHandle applicationHandle = 0;
static CAObjHandle workbookHandle = 0;
static CAObjHandle worksheetHandle = 0;

// and later

ExcelRpt_ApplicationNew(1, &applicationHandle);
ExcelRpt_WorkbookNew(applicationHandle, &workbookHandle);
ExcelRpt_WorksheetNew(workbookHandle, -1, &worksheetHandle);

 This should provide you with a valid handle for subsequent workbook operations.

 I hope this helps. Let us know if this works for you.

 

Best regards,

Peter


 

Message Edited by PaSB on 05-29-2009 03:41 PM
--
Peter A.
Field Sales Engineer, NI Germany
0 Kudos
Message 2 of 2
(3,608 Views)