Megosztás a következőn keresztül:


Workbook.WritePassword Property (2007 System)

Gets or sets the write password of a workbook.

Namespace:  Microsoft.Office.Tools.Excel
Assembly:  Microsoft.Office.Tools.Excel.v9.0 (in Microsoft.Office.Tools.Excel.v9.0.dll)

Syntax

'Declaration
Public Property WritePassword As String
'Usage
Dim instance As Workbook 
Dim value As String 

value = instance.WritePassword

instance.WritePassword = value
public string WritePassword { get; set; }
public:
property String^ WritePassword {
    String^ get ();
    void set (String^ value);
}
public function get WritePassword () : String 
public function set WritePassword (value : String)

Property Value

Type: System.String
The write password of a workbook.

Remarks

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

Examples

The following code example uses the WriteReserved property to determine whether the current workbook is write-reserved. If the workbook is not write-reserved, then the method sets the WritePassword property to a password obtained through user input. Otherwise, the example uses the WriteReservedBy property to display the name of the user who saved the workbook as write-reserved. This example assumes the existence of a method named GetPasswordFromUserInput that obtains a strong password from user input.

This example is for a document-level customization.

Private Sub SetWritePassword()
    If Not Me.WriteReserved Then 
        Me.WritePassword = GetPasswordFromUserInput()
    Else
        MsgBox("This workbook has been saved as Write Reserved." & _
            " Please contact " & Me.WriteReservedBy & " to add data.")
    End If 
End Sub
private void SetWritePassword()
{
    if (!this.WriteReserved)
    {
        this.WritePassword = GetPasswordFromUserInput();
    }
    else
    {
        MessageBox.Show("This workbook was saved as Write Reserved." +
            " Please contact " + this.WriteReservedBy + " to add data.");
    }
}

.NET Framework Security

See Also

Reference

Workbook Class

Workbook Members

Microsoft.Office.Tools.Excel Namespace