John Smith
John Smith

Reputation: 1

Unprotect Excel FIles using power automate

I have created Template excel file for my colleagues to upload their rosters each month, they do this by uploading the roster to Microsoft forms, then I manage to rename the excel sheets and move them to a new folder using power automate.

While the process is good and convenient, the Excel Template is protected with a password, and each time I am working with these large files I need to manually opens each one and then enter the password so I can work on them.

I am just asking if there is a way in power automate unprotected the sheet before move them to the final folder automatically since I have the password.

Searching google on this, and looking for post, but there was no answer near my question.

Upvotes: 0

Views: 6988

Answers (2)

Yi Lu
Yi Lu

Reputation: 1

after run the script for protected. There is nothing change in the workbook. workbook still can be open

Upvotes: 0

Skin
Skin

Reputation: 11262

Yep, use Office Scripts.

Never used Office Scripts before? If so, check out these links.

https://learn.microsoft.com/en-us/office/dev/scripts/overview/excel

https://support.microsoft.com/en-us/office/introduction-to-office-scripts-in-excel-9fbe283d-adb8-4f13-a75b-a81c6baf163a

This is a basic script which shows how to unprotect at the workbook level and the worksheet level respectively.

function main(workbook: ExcelScript.Workbook, password: string) {
    workbook.getProtection().unprotect(password);

    workbook.getWorksheets().forEach(sheet => {
        sheet.getProtection().unprotect(password);
    });
}

You're then able to call that script over any book from PowerAutomate using the Run script operation from the Excel online (business or OneDrive).

Run script

Upvotes: 0

Related Questions