View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Doug Glancy Doug Glancy is offline
external usenet poster
 
Posts: 770
Default Excel worksheets and VB .NET

Christopher,

I think you should take a look at Exception Handling (Try, Catch and Finally
or something like that) in VB.Net and catch the exception and deal with it
in VB.Net.

hth,

Doug Glancy

"Christopher Kain" wrote in message
...
Hi, I need to conditionally rename a worksheet in an excel 2000 workbook.
I have the following piece of code:
application.excel.worksheets("SheetName").Name = "NewSheetName"

which works to rename it. However, if SheetName doesn't exist or has been
renamed the program throws and exception. How can I check to make sure

that
a sheet exists in the sheets collection?