TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Paolo
NA
2
0
Cannot properly catch exceptions from Excel
Aug 30 2005 7:46 AM
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?!
Reply
Answers (
0
)
"Putting The Data to Excel Template"
Active Directory and .NET : paging the search result