the workbook's Unprotect function do not work #2547
fightingpjh
started this conversation in
General
Replies: 1 comment
-
See https://github.com/mhammond/pywin32#support for support requests. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
According to : https://docs.microsoft.com/zh-CN/office/vba/api/excel.workbook.unprotect
code:
xcl = win32com.client.Dispatch('Excel.Application')
xcl.visible = True
pw_str = raw_input("Enter password: ")
try:
wb = xcl.workbooks.open(filename, 0, False, None, pw_str, pw_str)
except Exception as e:
print "Error:", str(e)
sys.exit()
wb.Unprotect(pw_str)
wb.UnprotectSharing(pw_str)
wb.Save()
xcl.Quit()
it does't work, the excel file still protected.
Beta Was this translation helpful? Give feedback.
All reactions