Skip to main content

Selected-Area

Command Description

Select the designated area

Command Prototype

Excel.SelectRange(objExcelWorkBook,sheet,strRange)

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))
sheetTruestring"Sheet1"The string means sheet name. The number means sheet order(starting from 0)
strRangeTruestring"A1:B2"The specified cell, supports two forms: cell names (such as "A1:B2") or two-dimensional array of rows and columns (such as [[cell1 Row number, cell1 column number],[cell2 Row number, cell2 column number]]). When using cell names, it is case insensitive

Demo

/************************Selected area************************ ******** 
**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:
** sheet--If a string is used, it means the name of the specified worksheet; if a number is used, it means the order of the specified worksheet (starting from 0).
**Entry 3:
** strRange--Specified range, supports cell names such as "A1:B2" and two-dimensional row and column arrays such as [[cell 1 row number, cell 1 column number], [cell 2 Row number, cell 2 column number]] two forms, case-insensitive when using cell names.
**
*********************************************************************/

objExcelWorkBook = Excel.OpenExcel(@res"Test.xlsx",True,"Excel","","")
Excel.SelectRange(objExcelWorkBook,"Sheet1","A1:B2")
TracePrint "Selected area: Excel object Sheet1'A1:B2' area is selected"
Excel.CloseExcel(objExcelWorkBook,True)