Good Morning,
I am building a script which removes the read only property from a spreadsheet, opens the spreadsheet, removes the sheet protection, makes a change, readd the sheet protection and reapplies the read only property. However i keep getting an error on the protection.set_password part. The error i am getting is “TypeError: ‘bool’ object is not callable”
The code i am using is below. Does anyone know what is causing the error? as i am not 100% what the error means
import os
import stat
import openpyxl as op
from openpyxl import load_workbook
#Open workbook and check if FRN exists
file_name = r'c:\test.xlsx'
os.chmod(file_name, stat.S_IWRITE)
wb = op.load_workbook(file_name)
ws = wb.active
sheet = wb["Sheet1"]
sheet.protection.set_password = False
ws["A1"] = "TestValue"
pword = 'passw0rd11'
wb["Sheet1"].protection.set_password(pword)
wb.save(r"c:\test1.xlsx")
wb.close
os.chmod(file_name, stat.S_IREAD)