返回或设置一个工作簿的写密码。String 类型。可读写。
expression.WritePassword
expression 必需。该表达式返回“应用于”列表中的对象之一。
在本示例中,如果活动工作簿不能进行写保护,那么 Microsoft Excel 设置字符串密码以作为活动工作簿的写密码。
Sub UseWritePassword()
Dim strPassword As String
strPassword = "secret"
' Set password to a string if allowed.
If ActiveWorkbook.WriteReserved = False Then
ActiveWorkbook.WritePassword = strPassword
End If
End Sub
注意 WritePassword 属性可读并返回“********”。