DocumentBase.WritePassword 屬性

設定儲存文件變更的密碼。

命名空間:  Microsoft.Office.Tools.Word
組件:  Microsoft.Office.Tools.Word.v4.0.Utilities (在 Microsoft.Office.Tools.Word.v4.0.Utilities.dll 中)

語法

'宣告
Public WriteOnly Property WritePassword As String
    Set
public string WritePassword { set; }

屬性值

型別:System.String

備註

避免在您的應用程式中使用固定編碼密碼。 如果程序中需要密碼,請向使用者要求密碼,並將密碼儲存在變數中,再將變數用於程式碼中。

範例

下列程式碼範例會將 WritePassword 屬性設定為密碼,然後儲存文件。 下一次開啟文件時,會向使用者要求密碼。 此範例會假設 securePassword 參數是從使用者輸入取得的安全密碼。 若要使用這個範例,請在文件層級專案中的 ThisDocument 類別執行。

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 安全性

請參閱

參考

DocumentBase 類別

Microsoft.Office.Tools.Word 命名空間