Udostępnij za pośrednictwem


Document.WritePassword Property (2007 System)

Sets a password for saving changes to the document.

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

Syntax

'Declaration
Public WriteOnly Property WritePassword As String
'Usage
Dim instance As Document 
Dim value As String

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

Property Value

Type: System.String

Remarks

Avoid using hard-coded passwords in your applications. If a password is required in a procedure, request the password from the user, store it in a variable, and then use the variable in your code.

Examples

The following code example sets the WritePassword property to a password and then saves the document. The next time the document is opened the password will be requested. This example assumes that the securePassword parameter is a secure password obtained from user input.

This example is for a document-level customization.

Private Sub DocumentWritePassword(ByVal securePassword As String)
    Me.WritePassword = securePassword
    Me.Save()
End Sub
private void DocumentWritePassword(string securePassword)
{
    this.WritePassword = securePassword;
    this.Save();
}

.NET Framework Security

See Also

Reference

Document Class

Document Members

Microsoft.Office.Tools.Word Namespace