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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Excel Protected workbook
Power Automate
Suggested Answer

Excel Protected workbook

(0) ShareShare
ReportReport
Posted on by 6
Does anyone know if there is a way that the following can be done?
 
I have an excel attachment that comes via email to my flow that now has a password protection.  I need to know if there is a way remove this in the flow.  Thanks
I have the same question (0)
  • mmbr1606 Profile Picture
    14,615 Super User 2026 Season 1 on at
    hey
     
     
    what is the intention of the flow? please clarify
  • SM-17110845-0 Profile Picture
    6 on at
    to save email received from a shared email as an attachement (password protected) to update an existing table in sharepoint - this happens daily.  Then once a month the updated document in sharepoint is to be sent out to business via email but has to also be password protected.
  • Suggested answer
    rzaneti Profile Picture
    4,483 Super User 2026 Season 1 on at
     
     
    If your organization doesn't restrict its usage, you can go with Office Scripts for this task. You can either unlock an entire workbook, or some individual worksheets (as long as you have the passwords, of course).
     
    I'm sharing some blogs that I posted about Office Scripts, so you can have more context about it, but as a short description, it works like a VBA for Excel on the Web and it can be initialized by Power Automate:
    - Sending values from Power Automate to Excel with Office Scripts: https://digitalmill.net/2024/01/17/sending-values-from-power-automate-to-excel-with-office-scripts/
    - Debugging and accessing Office Scripts outputs with console.log: https://digitalmill.net/2024/09/09/debugging-and-accessing-office-scripts-outputs-with-console-log/
     
    First thing to do is to create your Script, which will look like this. Go to Automate tab and click New script:
     
     
    Then you can enter your script in the side pane:
     
    - You can use the code in line 5 to unprotect a workbook, just including the password between the parenthesis (in yellow).
    - You can use the code in line 7 to unprotect a worksheet, just including the sheet name (in green) and the password (in yellow) between the parenthesis. If you want to unprotect more than one worksheet, just copy/paste the same line, changing the sheet name and the password.
    - You can then use the lines 11 and 12 to protect it again, in the same or in other script, depending on your needs. For protecting the worksheet, you can use some custom settings as described here: https://learn.microsoft.com/en-us/javascript/api/office-scripts/excelscript/excelscript.worksheetprotection?view=office-scripts
     
    
    function main(workbook: ExcelScript.Workbook) {
    
    
        workbook.getProtection().unprotect('123') //Unprotect workbook
    
        workbook.getWorksheet('Sheet1').getProtection().unprotect('123') //Unprotect worksheet
    
    
        //PROTECTING AGAIN
        workbook.getProtection().protect('123')
        workbook.getWorksheet('Sheet1').getProtection().protect(null, '123')
    
    }
    
     
    After saving the Script, go to Power Automate and add a Run Script action, informing the file where you want to run it and the script to be used. In your case, since you're working with an email attachment, you will first need to save it to SharePoint or OneDrive:
     
     
    You can even pass dynamic values from PA to Office Scripts, following the instructions from the "Sending values from Power Automate to Excel with Office Scripts" blog, mentioned above. 
     
    Let me know if it works for you or if you need any additional help!
     
    If this solved your issue, please mark it as Accepted Answer.
    👍 If it helped, feel free to give it a like!

    🌐 Explore more Power Platform content on my Website or on my ▶️ YouTube
    💼 Find me on LinkedIn

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 605

#2
Valantis Profile Picture

Valantis 340

#3
11manish Profile Picture

11manish 284

Last 30 days Overall leaderboard