Protect Excel File

Sets a password to protect an Excel file.

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.

protectExcel --file(String) [--passwordtopen(String)] [--passwordtomodify(String)] (Boolean)=success (Excel)=value

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 Text, Excel Variable that stores the Excel instance.
Reading password passwordtopen Optional Text Password that allows only reading the contents of the file.
Modification password passwordtomodify Optional Text Password that allows you to modify the contents of the file.

Output parameters

Designer mode label Script mode name Accepted variable types Description
Success success Boolean Returns True if the file is protected, or False otherwise.
File value Excel Returns the protected Excel file.

Example

The command protects an Excel file with the defined password, allowing modification only using the same password.

defVar --name successProtect --type Boolean
protectExcel --file "sample file" --passwordtomodify automation123 successProtect=success
logMessage --message "Success: ${successProtect}" --type "Info"

Important: To run the sample script, create or use a sample excel file.