Hi,
I am converting to C# 2.0 a simple VB6 application I wrote to compare two Excel files.
I could manage to perform the main task (the comparison) but I am having some problems with error management.
For example, when the cell by cell comparison is running, I would like to see the current cell selected.
This should be as easy as the following:
theRange.Select()
Well, this call may fail due to several reasons: worksheet not active, protected , ecc.
What I want to do is just -try- to select and if an error occours... just ignore it.
In vb6 this was achieved with a simple
On Error Resume Next
theRange.Select
On Error Goto 0
It seemed that a try-catch block would have been the right C# solution:
try {
theRange.Select();
}
catch (Exception ex) {
System.Console.Out.WriteLine(ex.ToString());
}Here is what happens:
- the exception is caught by the catch block;
- the catch block is executed;
- the caller object is disposed (!!!) and the program stops executing.
Any idea?!