Document.WritePassword 屬性 (Word)

會設定用於將變更儲存到指定文件的密碼。 唯寫的 字串 。

語法

運算式。WritePassword

運算式 代表 Document 物件的變數。

註解

重要事項

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. 如需有關如何執行這項操作的建議最佳做法,請參閱 適用於 Office 解決方案開發人員的安全性注意事項。

範例

如果使用中文件尚未受到防止儲存變更的保護,本範例會將 "secret" 設定為文件的寫入密碼。

Set myDoc = ActiveDocument 
If myDoc.WriteReserved = False Then myDoc.WritePassword = "secret"

支援和意見反應

有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應。