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 Sheets
Add method, refer to Microsoft®
Excel documentation.
The Add method has the following optional
input arguments:
Before— The sheet before which to add the new sheetAfter— The sheet after which to add the new sheetCount— The total number of sheets to addType— 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.
eSheet1 = Item(eSheets,1); eNewSheet = Add(eSheets,[],eSheet1);
To call Add with the After argument,
omit the first argument, Before, by using an empty
array [] in its place.
Open the workbook and notice Sheet4.
Close the spreadsheet.
Close the application.
Quit(e) delete(e)