Workbook.HasPassword property (Excel)
True if the workbook has a protection password. Read-only Boolean.
expression A variable that represents a Workbook object.
You can assign a protection password to a workbook by using the SaveAs method.
This example displays a message if the active workbook has a protection password.
If ActiveWorkbook.HasPassword = True Then MsgBox "Remember to obtain the workbook password" & Chr(13) & _ " from the Network Administrator." End If
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.