Hi
Trying to delete a sheet from a Excel which contains Data,I am deleting the sheet through vb.net,here when the sheet is empty it is deleting,when it is non empty the sheet is not get deleted,
please suggest me with this
please verify code i have used
Dim excel As Microsoft.Office.Interop.Excel.Application
Dim wb As Microsoft.Office.Interop.Excel.Workbook
Dim ws As Microsoft.Office.Interop.Excel.Worksheet
Dim rng As Microsoft.Office.Interop.Excel.Range
excel = New Microsoft.Office.Interop.Excel.ApplicationClass
wb = excel.Workbooks.Open(newfile)
ws=CType(wb.Sheets(“Sheet2”),Microsoft.Office.Interop.Excel.Worksheet)
ws.Delete()
wb.Save()
wb.Close()
excel.Quit()
Thanks & Regards,
A Manohar