WritePassword Property

Microsoft Excel Visual Basic

WritePassword Property

       

Returns or sets a String for the write password of a workbook. Read/write.

expression.WritePassword

expression   Required. An expression that returns one of the objects in the Applies To list.

Example

In this example, if the active workbook is not protected against saving changes, Microsoft Excel sets the password to a string as the write password for the active workbook.

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

Note   The WritePassword property is readable and returns "********".