Insert Spreadsheet After First Sheet
This example shows how to skip an optional input argument in the Excel®
Add method, used to insert a sheet into a workbook. For
information about the
Add method, refer to Microsoft®
Add method has the following optional
Before— The sheet before which to add the new sheet
After— The sheet after which to add the new sheet
Count— The total number of sheets to add
Type— The type of sheet to add
e = actxserver('Excel.Application'); Add(e.Workbooks); e.Visible = 1;
Create a collection of the default sheets in the workbook.
eSheets = e.ActiveWorkbook.Sheets;
Insert a sheet after the first item in the collection,
eSheet1 = Item(eSheets,1); eNewSheet = Add(eSheets,,eSheet1);
Add with the
omit the first argument,
Before, by using an empty
 in its place.
Open the workbook and notice Sheet4.
Close the spreadsheet.
Close the application.