VBA EXCEL - 更改密码字符串时的可变密码错误

时间:2017-10-23 14:18:12

标签: excel vba excel-vba

在我的Excel工作簿中,我用密码保护了三张。 我将密码设置为模块中的常量

Option Explicit
Public Const strPassword As String = "password"

然后我保护ThisWorkbook中工作簿打开事件

中的工作表
Option Explicit

Private Sub Workbook_Open()

Sheets(1).Protect Password:=strPassword
Sheets(2).Protect Password:=strPassword
Sheets(3).Protect Password:=strPassword

End Sub

然后我在我的潜艇中使用Protect / Unprotect方法,如下所示:

Sheets(1).Unprotect Password:=strPassword

[...]

Sheets(1).Protect Password:=strPassword

一切都很好,直到我尝试使用“密码”之外的其他内容更改密码,更改后我收到错误的密码插入错误。 我无法理解为什么这不起作用......

0 个答案:

没有答案