Quantcast
Viewing all articles
Browse latest Browse all 14069

Unable to unprotect worksheet in openpyxl

I am running xlwings on Windows. When my code hits the unprotection of the sheet, the code just sits there. No exceptions, no popups appeared in Excel, just hanging. I can manually remove protection, the password is fine.

 with xw.App() as app:           wb = app.books(local_filename)        alerts = wb.api.Application.DisplayAlerts          wb.api.Application.DisplayAlerts = False        ws_data = wb.sheets["Data Input (Do not rename)"]        if wb.api.ProtectStructure:            wb.api.Unprotect(Password="xxx")        if ws_data.api.ProtectContents:            ws_data.api.unprotect(Password="xxx")  # hangs here forever

Viewing all articles
Browse latest Browse all 14069

Trending Articles