共用方式為


Excel) (Workbook.Password屬性

會傳回或設定開啟指定活頁簿所必須的密碼。 讀取/寫入的 String

語法

表達。密碼

代表 Workbook 物件的變數。

註解

Use strong passwords that combine uppercase and lowercase letters, numbers, and symbols. Weak passwords don't mix these elements.

  • 強密碼:Y6dh!et5
  • 弱密碼:House27

Passwords should be 8 or more characters in length. A pass phrase that uses 14 or more characters is better. 記住密碼至關重要。 If you forget your password, Microsoft cannot retrieve it. Store the passwords that you write down in a secure place away from the information that they help protect.

範例

在本範例中,Microsoft Excel 開啟名為 Password.xls 的活頁簿,設定其密碼,然後關閉活頁簿。 此範例假設 C:\ 磁碟機上存在名為 Password.xls 的檔案。

Sub UsePassword() 
 
 Dim wkbOne As Workbook 
 
 Set wkbOne = Application.Workbooks.Open("C:\Password.xls") 
 
 wkbOne.Password = InputBox ("Enter Password") 
 wkbOne.Close 
 
End Sub

支援和意見反應

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