简体   繁体   中英

Check whether worksheet is protected when no password has been specified

I have not been able to find any way to check whether an Excel Worksheet is in protected mode when a password hasn't been specified. I'm working with Office 2013 using the Excel Interop Assemblies.

If there is a password, you can check the HasPassword property, but when there is no password it does not appear that there is any method to determine whether the worksheet is currently protected.

I would also accept an event-based approach if there's any way to determine when the user selects to "Unprotect" the worksheet. The trouble right now is that when they do that, I don't know it's unprotected, and I can't respond appropriately.

Any ideas would be greatly appreciated, thanks!

为此,您可以尝试在没有密码的情况下取消保护工作表并在检查ProtectContents属性后捕获错误。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM