Microsoft Office Tutorials and References
In Depth Information
Worksheet manipulation
// Adding worksheet to our workbook
Excel.Worksheet AuthorWorksheet = Sheets.Add (missing,
missing, 1, missing) as Excel.Worksheet;
}
Code for deleting a worksheet from a workbook using VSTO:
private void ThisWorkbook_Startup(object sender,
System.EventArgs e)
{
// Code to delete the second sheet, referenced here as Sheets[2]
because we have not turned off the DisplayAlerts flag, a
warning message will be prompted before deleting
which causes a stop in the automated solution that requires
user input
((Excel.Worksheet)this.Application.ActiveWorkbook.
Sheets[2]).Delete();
}
The following screenshot shows how the code tries to delete the worksheet and how
the Excel application prompts the user to confirm the deletion.
 
Search JabSto ::




Custom Search