Excel VBA - Check if a worksheet is protected WITH A PASSWORD
问题 We can check if a sheet is protected using ProtectContents property. But how check if it is protected with a password? if ws.ProtectContents then ''do something end if 回答1: I don't believe there is a direct way of doing this by way of a property. Alternatively, though, you could attempt to unprotect the worksheet with a blank password and catch the error should it fail: Function isSheetProtectedWithPassword(ws As Worksheet) As Boolean If ws.ProtectContents Then On Error GoTo errorLabel ws