Skip to main content

Get-Current-Worksheet

Command Description

Get activated worksheet of a specified excel

Command Prototype

objRet = Excel.CurrentSheet(objExcelWorkBook,bRetName)

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))
bRetNameTruebooleanTrueTrue returns the table name. False returns the table index

return

objRet,The variable used to save the output of the command.

Demo

/************************Get current sheet************************ ********* 
**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:
** bRetName--whether to return the worksheet name, if true, return the table name, if false, return the table index
**Exports:
** objRet--Assign the result of running the command to this variable.
**
*********************************************************************/

objExcelWorkBook = Excel.OpenExcel(@res'''Test.xls''',true,"WPS","","")
objRet = Excel.CurrentSheet(objExcelWorkBook,true)
TracePrint "Get current worksheet: Get the currently open worksheet of the Excel object"
Excel.CloseExcel(objExcelWorkBook,True)