嘻皮客娱乐学习网
标题:
Excel 已知VBA工程密码,用代码实现自动解密的方法
[打印本页]
作者:
xipick
时间:
2017-2-8 16:28
标题:
Excel 已知VBA工程密码,用代码实现自动解密的方法
已知VBA工程密码为“123”,用代码实现自动解密VBA工程的方法
代码一,需要引用Microsoft Visual Basic For Application Extensibility 5.3
Sub OpenVBPrjWithPassword()
'引用 Microsoft Visual Basic For Application Extensibility 5.3
Dim strPassWord As String
'关闭VBE主窗口
Application.VBE.MainWindow.Visible = False
strPassWord = "123" '密码字符串
'判断是否设置了工程保护,使用密码打开工程
If ActiveWorkbook.VBProject.Protection = vbext_pp_locked Then
Application.VBE.CommandBars.FindControl(ID:=2578).Execute
SendKeys strPassWord & "{ENTER}{TAB}{ENTER}"
DoEvents '更新工程状态
End If
'要执行其它的操作….
'.....
End Sub
复制代码
代码二,不需要引用
Sub OpenVBPrjWithPassword()
Dim strPassWord As String
'关闭VBE主窗口
Application.VBE.MainWindow.Visible = False
strPassWord = "123" '密码字符串
'判断是否设置了工程保护,使用密码打开工程
If ActiveWorkbook.VBProject.Protection = 1 Then
Application.VBE.CommandBars.FindControl(ID:=2578).Execute
SendKeys strPassWord & "{ENTER}{TAB}{ENTER}"
DoEvents '更新工程状态
End If
'要执行其它的操作….
'.....
End Sub
复制代码
欢迎光临 嘻皮客娱乐学习网 (http://www.xipick.com/)
Powered by Discuz! X3.3