How can I tell if a worksheet exists in a workbook using VB.NET ?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Does anybody know of the best way to determine if a worksheet exists in an
Excel workbook using VB.NET?
 
Hi,
This not optimize solution but u can try with this one..........

dim intCounter as integer
Dim exlApp As New Excel.Application()
Dim exlBook As Excel.Workbook = exlApp.Workbooks.Open("c:\datas.xls")


For intCounter = 1 to exlBook.Worksheets.Count

if exlBook.Worksheets.item(intCounter).name = "NameTobechekced" then
messgebox.show("Sheet Exist")
end if
Next

I hope this will help u...............

Reagrds,
Ritesh
 
Back
Top