from openpyxl.workbook.protection import WorkbookProtection
import openpyxl as xl
wb = xl.load_workbook(path, keep_vba=True)
wb.security = WorkbookProtection()
wb.security.workbookPassword = 'test_password'
wb.security.lockStructure = True
ws = wb.active
# some code
wb.save(filename=path)
I tried to use the code above to password-protect an Excel file. There is no error but there is also no password prompt.
Can anyone help?