Forum Discussion
defcrash
Oct 04, 2023Copper Contributor
Excel file encrypt with password thru Office Scripts
Hi all,
I'm trying to automate adding a password to open an Excel file thru Office Scripts but it's being very difficult to me! I can do it with macros (VBA) but because the password must be added in power automate thru a SharePoint site I need to use Office Scripts (because I can't run macros on Excel Online)!
Can anyone help me with the code? I've tried everything... I've even tried chat gpt but the codes he gives me doesn't work! Chat gpt also advised me to use the Actions Record, but on my Windows Excel I don't have that button... the button only shows up for me in Excel online and in Excel online I cant add password encrypt...
Can anyone help me with the code? Or if anyone have the Actions record button in Windows Excel could please someone record the actions of adding a password encrypt to the file and post the code here!
Thank you very much in advance for your time!
If you change the formula to =A2-A3, you will see that the result is not exactly 0:
This is caused by tiny rounding errors. To avoid the problem, change the formula in A3 to
=ROUND(A1-TRUNC(A1,3),4)
(We round to 4 decimal places since your numbers have 4 significant decimal places)
5 Replies
Sort By
- JKPieterseSilver ContributorI'm afraid the answer is a simple blunt no, cannot be done. Office script cannot "handle files" in any way. It only works on the current document but cannot change things like the document name or encryption.
- defcrashCopper Contributor
JKPieterse thats what I was afraid of... 😥 Gotta think outside the box now... If anyone knows of any way to password encrypt (or decrypt) an Excel file thru power automate I'll be really appreciated! Thanks again for your time and help!
- JKPieterseSilver Contributor