DocumentBase.Password 屬性

設定開啟文件時必須提供的密碼。

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

語法

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

屬性值

型別:System.String
開啟文件時必須提供的密碼。

備註

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

範例

下列程式碼範例會將文件密碼設定為使用者傳入的文字。 若要使用這個範例,請在文件層級專案中的 ThisDocument 類別執行。

Private Sub DocumentPassword(ByVal PasswordFromUser As String)
    Me.Password = PasswordFromUser
End Sub 
private void DocumentPassword(string PasswordFromUser)
{
    this.Password = PasswordFromUser;
}

.NET Framework 安全性

請參閱

參考

DocumentBase 類別

Microsoft.Office.Tools.Word 命名空間