Project.HasPassword 属性 (Project)

如此 如果一个项目有密码。 只读 Boolean

语法

expressionHasPassword

表达 一个代表 Project 对象的变量。

备注

注意

[!注释] 项目可以打开 ODBC 数据库中存储密码,但不能将文件保存到数据库项目文件。

示例

以下示例将显示有密码的打开项目的列表。

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.HasPassword Then 
            NameList = NameList & P.Name & vbCrLf 
        End If 
    Next P 
 
    ' Display information about projects with passwords. 
    If NameList = "" Then 
        MsgBox("No open projects have passwords.") 
    Else 
        MsgBox("The following open projects have passwords: " & vbCrLf & vbCrLf & NameList) 
    End If 
End Sub

支持和反馈

有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。