LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Saving workbook in excelreportdemo

I am building an application based on excelreportdemo.prj.

I need to save the contents of the ActiveX document workbook on the UIR before I quit. The *.xls file is being generated however the workbook contents are not saved.

The following code is obtained from "excelreportdemo.c" with the ExcelRpt_WorkbookSave command added.

Is this the correct way to do it?

//****************************************************************************************************
// Quit
//****************************************************************************************************

int CVICALLBACK Quit (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
switch (event)
{

case EVENT_COMMIT:

//---------------------------------
// Piece of inserted code
//---------------------------------

ExcelRpt_WorkbookSave (workbookHandle, "c:\\SavedData.xls", ExRConst_DefaultFileFormat);

//---------------------------------


if (worksheetHandle)
CA_DiscardObjHandle(worksheetHandle);
if (workbookHandle)
CA_DiscardObjHandle(workbookHandle);
if (chartHandle)
CA_DiscardObjHandle(chartHandle);

QuitUserInterface (0);
break;
}
return 0;
}


Thanks,
Raphael
0 Kudos
Message 1 of 6
(2,931 Views)
Hello Raphael,

Try examining the �excel200dem.prj� example. It has the functionality you are looking for.

If this suggestion doesn�t help, or if I�m not correctly understanding your issue, please post the software and versions you are using, the applicable portions of your code, and any other information that may help, and I�ll be happy to look further into it.

Have a nice day!

Robert M
Applications Engineer
National Instruments
Robert Mortensen
Software Engineer
National Instruments
0 Kudos
Message 2 of 6
(2,931 Views)
Dear Robert,

Thanks for your reply. I have already tried to use the "excel2000dem.prj" and it works fine as long as excel is launched using "ExcelRpt_ApplicationNew" or the "longer" way as shown in "excel2000dem.prj".

The problem appears to occur when (as in excelreportdemo) Excel is embedded in the UIR as a Microsoft Excel Workbook by using Create->ActiveX->Create Document(from drop down menu).

As stated earlier, the file is created however, the data is not inserted in the file.

Basically, I require to save the data on a workbook which is an ActiveX Document on the UIR exaclty as is excelreportdemo.prj.

Thanks for your time,
Raphael
0 Kudos
Message 3 of 6
(2,931 Views)
PS. I am using LabWindows/CVI Ver6, on Windows2000 and Office XP.

Thanks
Raphael
0 Kudos
Message 4 of 6
(2,931 Views)
Raphael,

I was able to reproduce exactly what you are experiencing. After a lot of research and digging, I found out that Excel will not allow embedded files to be saved without first opening the Excel application, as done in the other example program I suggested. You will have to open up Excel as its own application before you can save anything to it. More documentation about the Excel ActiveX function calls can be found at msdn.microsoft.com.

Hope this helps, and have a great day!
Robert M
Applications Engineer
National Instruments
Robert Mortensen
Software Engineer
National Instruments
0 Kudos
Message 5 of 6
(2,931 Views)
Thanks for your help.

Raphael
0 Kudos
Message 6 of 6
(2,931 Views)