Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

is possible to catch exceptions thrown by CNIExcel* objects?

Hello all,

 

I'm using CNiExcel* classes to create reports, but in some cases Excel process is still running when application is finished.

It looks like an exception is thrown in methods from CNiExcel* classes. Is there possibility to catch this exception (not by using of catch (...) )?

 

Thanks for reply

 

 Miro

0 Kudos
Message 1 of 4
(5,744 Views)

Hey juriga,

 

I had some trouble finding documentation on this particular object and was wondering if I could get some more information about your project.

 

What language are you using?

What version of Excel are you using?

What indicates that exceptions are being thrown?

What cases does it seem like Excel is still open?

How are you closing out the references? Maybe the program is ending before it gets to your clean up routine. 

 

Let me know the answers to this when you have a chance.

 

Best Regards,

 

-KP

Kurt P
Automated Test Software R&D
0 Kudos
Message 2 of 4
(5,734 Views)

Hello Kurt,

With CNiExcel* I mean classes CNiExcelApplication, CNiExcelWorkbook, CNiExcelWorkSheet and CNiExcelCellRange.

>What language are you using?

Application is in C++ and using Maesurement Studio 8.1 for Visual Studio 2005.

>What indicates that exceptions are being thrown?

Exception catched via catch(,,,) block

>What cases does it seem like Excel is still open?

Sometimes, when routine which create XLS report is finished, Excel process is still visible in "Process" tab in "Windows Task Manager", but not in "Application list" in TaskBar

>How are you closing out the references? Maybe the program is ending before it gets to your clean up routine.

Steps in routine creates XLS:
- Open Excel
- Fill Content
- Close Excel

Open Excel:

    excelApplication = new CNiExcelApplication(true);
    excelWorkbook = new CNiExcelWorkbook(excelApplication->NewWorkbook());
    excelWorksheet = new CNiExcelWorksheet(excelWorkbook->GetWorksheet(1));

Close Excel:

   if (excelWorksheet)
        delete excelWorksheet;
    if (excelWorkbook)
        delete excelWorkbook;
    if (excelApplication)
        delete excelApplication;

 

 

Best Regards,

 

Miro

0 Kudos
Message 3 of 4
(5,728 Views)

Hey juriga,

 

Thank you for the information. I found that library uses Office object model from this Knowledgebase (towards the end). You can try to set the objects (or the pointers to these objects) to NULL since some reference is not closing out. This is software is legacy so the documentation for it is difficult to find. There may be some ActiveX automation server that you can call to shut down Excel but that would be something on Microsoft's end and therefore not familiar with. Also what version of Microsoft Office are you using? If it is a new version there is a chance there is some new references that is not considered by that library.

 

Best Regards,

 

-KP

Kurt P
Automated Test Software R&D
0 Kudos
Message 4 of 4
(5,713 Views)