True if a project has a password. Read-only Boolean.
expression A variable that represents a Project object.
The following example displays a list of open projects that have passwords.
Visual Basic for Applications
Dim P As Project ' Project object used in For Each loop
Dim NameList As String ' Names of projects with passwords
' Check each open project for passwords.
For Each P in Application.Projects
' If a project has a password, add its name to the list.
If P.<strong class="bterm">HasPassword</strong> Then
NameList = NameList & P.Name & vbCrLf
' Display information about projects with passwords.
If NameList = "" Then
MsgBox("No open projects have passwords.")
MsgBox("The following open projects have passwords: " & vbCrLf & vbCrLf & NameList)