web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Need help in creating ...
Power Automate
Unanswered

Need help in creating a password protected excel file using Power Automate

(1) ShareShare
ReportReport
Posted on by 20

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

Categories:
I have the same question (1)
  • sandeepstw Profile Picture
    312 Moderator on at

    Hi There,

     

    Power Automate does not support the direct creation of a password-protected Excel, you need to use a custom connector or any other API for the same. 

     

    Please give kudos and mark as solution if it helps.  

      

    Thanks, 

    Sandeep Mishra 

     

  • sandeepstw Profile Picture
    312 Moderator on at

    Please mark this question as solution if it helps. 

     

  • Disha2023 Profile Picture
    20 on at

    Hi @sandeepstw ,

     

    Thanks for your suggestion.

    But can you please guide through the use of custom connector or API which you had mentioned in your reply.

     

    Thanks

  • Disha2023 Profile Picture
    20 on at

    @sandeepstw 

    I need more details on custom connector and how to use them in this case.

  • sandeepstw Profile Picture
    312 Moderator on at

    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

     

  • Disha2023 Profile Picture
    20 on at

    @sandeepstw , I am using Power Automate online app. Can you please guide me in that?

     

  • sandeepstw Profile Picture
    312 Moderator on at

    You need to create it, there is nothing like that as much I know. 

     

  • Rhiassuring Profile Picture
    8,690 Moderator on at

    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://learn.microsoft.com/en-us/javascript/api/office-scripts/excelscript/excelscript.worksheetprotection?view=office-scripts

     

    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:

     

    Rhiassuring_0-1690586395427.png

     

    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 🙂 

     

     

  • Disha2023 Profile Picture
    20 on at

    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

  • Disha2023 Profile Picture
    20 on at

    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

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard