Document.Password Property (2007 System)
Sets a password that must be supplied to open 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 Password As String
'Usage
Dim instance As Document
Dim value As String
instance.Password = value
public string Password { set; }
public:
property String^ Password {
void set (String^ value);
}
public function set Password (value : String)
Property Value
Type: System.String
A password that must be supplied to open the document.
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 password of the document to text passed in by the user.
This example is for a document-level customization.
Private Sub DocumentPassword(ByVal PasswordFromUser As String)
Me.Password = PasswordFromUser
End Sub
private void DocumentPassword(string PasswordFromUser)
{
this.Password = PasswordFromUser;
}
.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.