01-27-2008 12:03 PM
01-27-2008 01:28 PM
01-27-2008 11:47 PM
01-28-2008 07:58 AM
Hi Roberto,
In the past I remember discovering that Excel remains in Task Manager after my app exits if (I cannot say "only if") there is a handle left unterminated.
I also noticed your code looks like it uses 1-based indexing for sheets. Are you sure it is not 0-bases?
If there is an error due to this logic, your code may jump to the "cleanup" without passing through ClearObjHandle function, hence leaving the handle unterminated.
I cannot "dig" down any further from the given piece of code. So I hope this much helps.
Good luck!
01-28-2008 08:30 AM
Thanks Eren for the suggestion: I have observed too that an active handle leaves excel in the Task Manager, but it seems that this is not the problem in this case. I have verified that Item property is a 1-based index: with 4 sheets created by default, trying to delete from index 2 to 3 deletes the second sheet (where I have written my data) and 3, leaving the last untouched (but empty ). Based on your suggestion, I tried step-running my code and I received a not-better-specified exception when selecting (Excel_SheetsItem) the last sheet: in this case no handle should be active, since I have already cleared the previous handle, but the excel instance is still present in Task Manager...
Ok, maybe the better is to leave the empty sheets there and go on with something else: the operator receives also a confirmation question for each sheet to be deleted!