I'm trying to delete a worksheet from a excel document from a .Net c# 3.5 application with the interop Excel class (for excel 2003).
I try many things like :
Worksheet worksheet = (Worksheet)workbook.Worksheets[1]; worksheet.Delete();
It's doesn't work and doesn't throw any error ...
Worksheet worksheet = (Worksheet)workbook. Worksheets[1]; worksheet. Delete();
On the Home tab, in the Cells group, click the arrow next to Delete, and then click Delete Sheet. Tip: You can also right-click the sheet tab of a worksheet or a sheet tab of any selected worksheets that you want to delete, and then click Delete Sheet.
You can also press ALT + F8 to open the Macro dialog box. ❼ From the Macro dialog box, select the function name of the VBA code and hit Run. This will instantly delete the sheet that you have inserted in the VBA code without showing any prompt warning message.
To delete a sheet using VBA, you need to use the VBA Delete method. You need to specify the sheet that you want to delete and then use this method. Let's say if you want to delete the “Sheet1”, then you need to mention sheet1 and then type a dot (.) and in the end, type “Delete”.
After more than one hour looking I found the answer:
xlApp.DisplayAlerts = false; worksheet.Delete(); xlApp.DisplayAlerts = true;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With