i’ve search for any method to encrypt our excel with password (add password to our exsiting file), i mean not just protect sheet or workbook, but all the file. For comparison, if u do it in excel manually you can go through this = Info>Protect Workbook>Encrypt with Password
You can encrypt the whole excel file by using the VBA code.
Take one Excel process scope
Place the Use excel file activity inside the Excel process scope.
Give the path of the file in the use excel file activity.
Inside the Use excel file activity drag and drop the Invoke VBA activity.
Store the below expression in a notepad and save it as a document and copy the path
Sub EncryptWorkbook()
ActiveWorkbook.Password = "YourPassword"
End Sub
In invoke VBA activity
→ In target workbook option give the “Excel” that was in the use excel file reference.
→ In Code file path pass the notepad path.
→ In Entry Method name give the name as “EncryptWorkbook”
Hi, thanks for sharing,
however, whatever the password that we were using i need to share with user over the email, how to i get the password from vba script to studio.?