Quantcast
Channel: Microsoft Dynamics AX Forum - Recent Threads
Viewing all articles
Browse latest Browse all 72043

Shutdown Excel after an exception is thrown

$
0
0

I'm importing data from Excel into AX using the following X++ code:

SysExcelApplication application;

application = SysExcelApplication::construct();

{ open excel file }

{ process data }

application.quit();

The application.quit() method shuts down the Excel process.

Here is the problem: if there is an error and an exception is thrown in the processing, this code is never reached, so there is a hidden EXCEL.EXE process running in the background (shown in task manager).

So far I have come up with the following:

1. Put the code in a try{} block and put quit() in the catch{} block. The problem is this is that when an exception is thrown, the execution goes to the outermost TTS level, so this won't always work.

2. I have made Excel visible with "application.visible(true);". This way, if the application doesn't quit then at least it is visible so the user can manually shut it down. This is more of a workaround.

Neither of these solutions seem very clean. Any suggestions for a better way of handling this are welcome.

Thanks,

Nehal


Viewing all articles
Browse latest Browse all 72043

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>