Project.HasPassword Property

Project Developer Reference

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
  Sub ListProjectsWithPasswords()
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 &amp; P.Name &amp; vbCrLf
    End If
Next P

' Display information about projects with passwords.
If NameList = "" Then
    MsgBox("No open projects have passwords.")
    MsgBox("The following open projects have passwords: " &amp; vbCrLf &amp; vbCrLf &amp; NameList)
End If

End Sub

See Also