Share via


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 支援與意見反應