Rename Excel Worksheet

Renames a worksheet from an Excel file, located by index or name.

Command availability: IBM RPA SaaS and IBM RPA on premises

Script syntax

IBM RPA's proprietary script language has a syntax similar to other programming languages. The script syntax defines the command's syntax in the script file. You can work with this syntax in IBM RPA Studio's Script mode.

excelRenameWorksheet --file(Excel) [--index(Numeric)] [--name(String)] --newname(String)

Dependencies

  • To use this command, open an Excel file with the Open Excel file (excelopen) command.

Input parameters

The following table displays the list of input parameters available in this command. In the table, you can see the parameter name when working in IBM RPA Studio's Script mode and its Designer mode equivalent label.

Designer mode label Script mode name Required Accepted variable types Description
Excel file Required Excel Variable that stores the Excel instance.
Index index Optional Number Spreadsheet index to be renamed.

Important: The index starts at 1 and must be an existing value in the Excel file.
Name name Optional Text Name of the worksheet to be renamed.
New Name newname Required Text New name for the worksheet.

Example

The Open Excel File command opens an Excel file and stores it in the variable named "excelFile". The Rename Excel Worksheet command finds the spreadsheet of Index "1" and renames it to "FirstSheet".

defVar --name excelFile --type Excel
// Download the following file to run the command.
excelOpen --file "Sample file" excelFile=value
excelRenameWorksheet --file ${excelFile} --index 1 --newname FirstSheet
excelClose --file ${excelFile} --save

Important: To run the sample script, create the file and add its path in the File Path parameter.

Limitations

The files referenced when running the Open Excel File (excelopen) command must be closed in order for the command to work.