Skip to main content

Notifications

Community site session details

Community site session details

Session Id : FlsfZrGEtzv56Ce2vEmVCs
Power Automate - General Discussion
Unanswered

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

Like (1) ShareShare
ReportReport
Posted on 28 Jul 2023 16:24:16 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

  • sandeepstw Profile Picture
    302 Super User 2025 Season 1 on 29 Jul 2023 at 09:26:00
    Re: Need help in creating a password protected excel file using Power Automate

    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. 

     

  • Disha2023 Profile Picture
    20 on 29 Jul 2023 at 07:30:28
    Re: Need help in creating a password protected excel file using Power Automate

    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.

  • Rhiassuring Profile Picture
    8,688 Super User 2025 Season 1 on 29 Jul 2023 at 07:23:39
    Re: Need help in creating a password protected excel file using Power Automate

    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. 

  • Disha2023 Profile Picture
    20 on 29 Jul 2023 at 05:55:09
    Re: Need help in creating a password protected excel file using Power Automate

    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

  • Disha2023 Profile Picture
    20 on 29 Jul 2023 at 02:23:25
    Re: Need help in creating a password protected excel file using Power Automate

    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

  • Rhiassuring Profile Picture
    8,688 Super User 2025 Season 1 on 28 Jul 2023 at 23:21:13
    Re: Need help in creating a password protected excel file using Power Automate

    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 🙂 

     

     

  • sandeepstw Profile Picture
    302 Super User 2025 Season 1 on 28 Jul 2023 at 17:03:08
    Re: Need help in creating a password protected excel file using Power Automate

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

     

  • Disha2023 Profile Picture
    20 on 28 Jul 2023 at 16:59:28
    Re: Need help in creating a password protected excel file using Power Automate

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

     

  • sandeepstw Profile Picture
    302 Super User 2025 Season 1 on 28 Jul 2023 at 16:57:56
    Re: Need help in creating a password protected excel file using Power Automate

    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 28 Jul 2023 at 16:57:54
    Re: Need help in creating a password protected excel file using Power Automate

    @sandeepstw 

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

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Automate - General Discussion

#1
David_MA Profile Picture

David_MA 8 Super User 2025 Season 1

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 8 Super User 2025 Season 1

#3
ankit_singhal Profile Picture

ankit_singhal 7 Super User 2025 Season 1

Overall leaderboard