I want to apply password on excel file. But due to restriction , Microsoft office is not installed so cant use excel application scope.
How can we archive this
Does any kind of code will help
I want to apply password on excel file. But due to restriction , Microsoft office is not installed so cant use excel application scope.
How can we archive this
Does any kind of code will help
Sorry buddy hard luck there is no way without MS Office installation.
@jose.ordonez1 's way also will not work as it also has dependency on MS Office library.
Thanks,
Ashok ![]()
Why not use a credentials asset to store the password, since that’s what it’s designed for?
Hi TUSHAR_DIWASE,
Please check this url.
Cheers!
Yes, you can use UiPath to apply a password to an Excel file without using the Excel Application Scope activity. You can achieve this by using the Invoke Code activity in UiPath along with the Interop library to manipulate Excel files. Here’s a general outline of the steps you can follow:
Here’s an example of C# code you can use inside the Invoke Code activity:
csharpCopy code
using Microsoft.Office.Interop.Excel;
public void SetExcelPassword(string filePath, string password)
{
Application excelApp = new Application();
Workbook workbook = excelApp.Workbooks.Open(filePath);
workbook.Password = password;
workbook.Save();
workbook.Close();
excelApp.Quit();
}
Make sure to adjust the file path and password parameters according to your needs.
Remember to handle exceptions and error checking appropriately in your workflow. Also, note that using the Interop library may require additional setup on your machine, such as installing the “Microsoft.Office.Interop.Excel” package via NuGet.
How about compressing the file to a zip and apply password? It could be done with UiPath activities (Activities - Compress/Zip Files).