共用方式為


DocumentBase.WritePassword Property

Definition

Sets a password for saving changes to the document.

public:
 property System::String ^ WritePassword {  void set(System::String ^ value); };
public string WritePassword { set; }
member this.WritePassword : string
Public Property WritePassword As String

Property Value

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 void DocumentWritePassword(string securePassword)
{
    this.WritePassword = securePassword;
    this.Save();
}
Private Sub DocumentWritePassword(ByVal securePassword As String)
    Me.WritePassword = securePassword
    Me.Save()
End Sub 

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.

Applies to