Skip to main content

Create-Worksheet

Command Description

Create a sheet, insert it before or after the currently active sheet, and the sheet will be activated after creation

Command Prototype

Excel.CreateSheet(objExcelWorkBook,strSheetName,strWhere,bSave)

Parameter Description

ParameterRequiredTypeDefaultDescription
objExcelWorkBookTrueexpressionobjExcelWorkBookExcel workbook object (workbook opened with "Open Excel" command (Excel.OpenExcel) or the workbook object returned by the command "Bind Excel" (Excel.BindBook))
strSheetNameTruestring"newSheet"Name of the new created worksheet
strWhereTrueenum"after"The sheet used as a location reference when a sheet is created
bSaveTruebooleanNoneSave immediately after the operation

Demo

/************************Create worksheet************************ ********* 
**Input 1:
** objExcelWorkBook -- Excel workbook object (a workbook opened using the "Open Excel" command (Excel.OpenExcel) or a work bound using the "Bind Excel" command (Excel.BindBook) book object).
**Entry 2:
** strSheetName--The name of the new sheet created.
**Entry 3:
** strWhere--The worksheet used as the location reference when creating the worksheet.
**Entry 4:
** bSave--The operation is completed and saved immediately. (boolean true/false)
**
*********************************************************************/

objExcelWorkBook = Excel.OpenExcel(@res"Test.xlsx",True,"Excel","","")
Excel.CreateSheet(objExcelWorkBook,"newSheet","after",False)
TracePrint "Create sheet: Excel object inserts new sheet named 'newSheet' after reference sheet"
Excel.CloseExcel(objExcelWorkBook,True)