Hi,
I am trying to create a password protected Excel file using Power Automate but unable to do so.
Can anyone please help me resolve this issue?
Thanks,
Disha
Yes, for that, you can use Azure API, or you can use the Power Automate Desktop version. There is no inbuild connector for creating password protected files.
Hi @Rhiassuring ,
Thanks for your reply.
Actually the issue mentioned in message#10 has been resolved.
The only issue I am facing is that the password protected file which I have created whenever I will try to open it should ask for password.
This is a password protected sheet. It means you can not modify the sheet, you will see a lock on it. If you want to password protect the whole file, check this out:
https://exceloffthegrid.com/office-scripts-workbook-worksheet-protection/#Protect_a_workbook
Your earlier comment, you are asking about populating the Excel file itself. That is a whole other question, and, should probably come before you protect the file! Protecting the file should be the last step.
Hi @Rhiassuring ,
I tried your solution but when I am trying to open the excel to which the script is applied, it is not asking for any password to open the file. The file is simply opening as normal
Hi @Rhiassuring ,
Thanks for your suggestion. It's of great help.
Just one thing I would like to know. I also want to populate data into this password protected file using power automate. So the step which you had mentioned, after that if I use 'create table' connector, then 'add row into table' connector will data get populated in this password protected file?
Can you please help me with that as well @Rhiassuring
Thanks
Hi @Disha2023 ,
Yes, this is achievable, without an API or Third Party Connector (a note for @sandeepstw )
If you are doing this for a one time Excel file, you can create the script inside of it and run that.
If this is something repeatable (you want to create a new file, and apply the script to it), then you'll make a little template.
So, it goes like this:
Step 1) In a SharePoint Library (or in OneDrive, doesn't matter, both count as "SharePoint"), Create an Excel template where you can host your script. (Can just be a plain ole' Excel file. I just called mine ExcelScripts so I'd know what I made it for. Has no content.)
Step 2) Create your script inside of your file (click on "Automate", "New Script", paste it in, save, exit. Yep, that easy.)
function main(workbook: ExcelScript.Workbook) {
// Get the current worksheet.
let selectedSheet = workbook.getActiveWorksheet();
//Assign the Sheet1 worksheet to the ws variable
let ws = workbook.getWorksheet("Sheet1");
//Protect worksheet with a password
ws.getProtection().protect({}, "PowerAutomate");
}
"Sheet1" is the name of the Sheet you want to protect. If you have more than one sheet, or want to protect the whole workbook, check out these options:
https://exceloffthegrid.com/office-scripts-workbook-worksheet-protection/
"PowerAutomate" is the password I've chosen for the example.
Step 3) When you are ready to run your flow to apply the script to another Excel file, it will look like this:
Workbook Location, Workbook Library, and Workbook refer to the Excel file that you want to APPLY the script to.
Script Location, Script Library, and Script refer to your Template. You will find that your *.osts file will appear in the same directory as where ever you saved your Template (unless you move the script, of course.)
That's it.
It might look overwhelming, but I'll mention:
- I am not a coder.
- I have never done this before today.
You got this 🙂
You need to create it, there is nothing like that as much I know.
@sandeepstw , I am using Power Automate online app. Can you please guide me in that?
but yes
Power Automate Desktop, which allows you to automate UI-based actions. There you can create a Password Protected as humans do.
Please give kudos and mark as solution if it helps.
Thanks,
Sandeep Mishra
I need more details on custom connector and how to use them in this case.
David_MA
8
Super User 2025 Season 1
Michael E. Gernaey
8
Super User 2025 Season 1
ankit_singhal
7
Super User 2025 Season 1