Reputation: 831
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!
Upvotes: 1
Views: 1425
Reputation: 2733
You do this by trying to unprotect the sheet without a password and catching the error after checking the ProtectContents
property.
Upvotes: 2