简体   繁体   English

VBA保护功能应用错误的密码

[英]VBA Protect Function Applies the Wrong Password

I start the Workbook_Open event with this line of code 我用这行代码启动了Workbook_Open事件

Table1.Protect Password = "Secret", UserInterFaceOnly:=True

However, when I try to unlock it with 但是,当我尝试用它解锁时

Table1.Unprotect ("Secret")

it does not work. 这是行不通的。

The Password Cracker says, that a working password would be "AAAAAAAABABF" 密码破解者说,工作密码将是“AAAAAAAABABF”

How do I actually set "Secret" as the password. 我如何实际设置“秘密”作为密码。

It's a common mistake (so common I wrote this: http://excelmatters.com/2013/10/03/whats-in-a-colon/ ). 这是一个常见的错误(我写的很常见: http//excelmatters.com/2013/10/03/whats-in-a-colon/ )。

Your Protect code is missing a colon: 您的Protect代码缺少冒号:

Table1.Protect Password:="Secret", UserInterFaceOnly:=True

You were actually protecting the workbook with the password False, since that's the result of the expression: 您实际上是使用密码False保护工作簿,因为这是表达式的结果:

Password = "Secret"

TL;DR Read the article that Rory wrote (in his answer below) TL; DR阅读Rory写的文章(在下面的答案中)

Firstly, your protect code is wrong (missing a colon : ): 首先,你的保护代码是错误的(缺少一个冒号: ):

Table1.Protect Password = "Secret", UserInterFaceOnly:=True

This is assigning Password which will be treated as an undeclared variable (did you forget to use Option Explicit ?) 这是分配Password ,将被视为未声明的变量(您是否忘记使用Option Explicit ?)

It should be this: 它应该是这样的:

Table1.Protect Password:= "Secret", UserInterFaceOnly:=True

The Password Cracker says, that a working password would be "AAAAAAAABABF" 密码破解者说,工作密码将是“AAAAAAAABABF”

This is because these kinds of passwords in Excel are not secure (this is well documented). 这是因为Excel中的这些密码不安全(这是有详细记录的)。 Passwords of this nature in Excel rely on more of a numerical value where each character is assigned a numeric value... so: Excel中这种性质的密码依赖于更多的数值,其中每个字符都分配了一个数值......所以:

d = 4
a = 1

(a + a + a + a) = d

and so in this case using d or aaaa would work as your password. 所以在这种情况下使用daaaa将作为您的密码。 (This is a crude example of how it works, not the exact methods). (这是它如何工作的原始示例,而不是确切的方法)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM