I have made a form that can import any table with any no. of fields specified, from an excel file. This is done using excel automation. The problem is that when a file has some improper field type (ex: for an imteger column, it has some text), then an error occurs telling that this problem has occurred and the whole operation stops. That is ok because it must throw error to tell that the file has problem. But after the error, the Excel Automation server stays open because the code for closing is not executed. Then the user needs to close it manually from task manager.
Is there any way to handle this kind of exception? In C++ or Java or in Axapta also, this can be stopped by Try – Catch Blocks, is there anything possible for navision?
I have done the same as you have. It helps me very much except for some cases where the table has some validation properties and the validation throws errors. In these cases the system suddenly stops without clearing the Excel. Validate trigger also does not have any output type so that i can use this in any IF ELSE block. Guess this is the only way. Anyway, Thank you BOTH for your helps and to make me sure that there is no other way.
If You’re on 5.0, You could look into GETLATESTERRORTEXT & CLEARLATESTERROR (found in the C/AL-symbol menu, under SYSTEM - Error-handling).
Maybe these can help You achieve what You want.
If they can do the trick for You, and You’re not on 5.0, You can consider a technical upgrade, just to have that functionality available.
The RIM toolset does exactly what you are doing here (although the hangiong Excel task is a problem. You should download this and have a look. Also the Data Migration toolset addresses this issue/