Anteckning
Åtkomst till den här sidan kräver auktorisering. Du kan prova att logga in eller ändra kataloger.
Åtkomst till den här sidan kräver auktorisering. Du kan prova att ändra kataloger.
Sets a password for saving changes to the document.
Namespace:  Microsoft.Office.Tools.Word
Assembly:  Microsoft.Office.Tools.Word.v4.0.Utilities (in Microsoft.Office.Tools.Word.v4.0.Utilities.dll)
Syntax
'Declaration
Public WriteOnly Property WritePassword As String
    Set
public string WritePassword { set; }
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. To use this example, run it from the ThisDocument class in a document-level project.
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
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.