Skip to content

Latest commit

 

History

History
50 lines (30 loc) · 1.25 KB

Word.Document.Password.md

File metadata and controls

50 lines (30 loc) · 1.25 KB
title keywords f1_keywords api_name ms.assetid ms.date ms.localizationpriority
Document.Password property (Word)
vbawd10.chm158007381
vbawd10.chm158007381
Word.Document.Password
243f1735-5367-4ac9-5643-624ccf501abe
06/08/2017
medium

Document.Password property (Word)

Sets a password that must be supplied to open the specified document. Write-only String.

Syntax

expression. Password

expression A variable that represents a Document object.

Remarks

Important

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. For recommended best practices on how to do this, see Security notes for Office solution developers.

Example

This example opens Earnings.doc, sets a password for it, and then closes the document.

Set myDoc = Documents _ 
 .Open(FileName:="C:\My Documents\Earnings.doc") 
myDoc.Password = strPassword 
myDoc.Close

See also

Document Object

[!includeSupport and feedback]