|
找了一个可以判断VBA Project是否被加密保护,如果有自动解除VBA保护和密,当然条件满足也就可以执行想执行的VBA小程序。
但遇了一个怪问题,在一部份机上运行正常,但有一部分机子上运行,在弹出VBAProject属性框之后就停那了。。。莫名呀。
求助,这方面用过的老师指点下。
Private Sub Workbook_Open()
On Error Resume Next
Application.DisplayAlerts = False
Application.ScreenUpdating = False
If ThisWorkbook.VBProject.Protection = 1 Then
Application.SendKeys "%{F11}", True
Application.SendKeys "%T", True
Application.SendKeys "e", True
myPW = "admin"
Application.SendKeys myPW, True
Application.SendKeys "{ENTER}", True
Application.SendKeys "{ENTER}", True
Application.SendKeys "%{F11}", True
Application.SendKeys "%{F11}", True
Application.SendKeys "%T", True
Application.SendKeys "e", True
myPW = "admin"
Application.SendKeys "^{TAB}", True
Application.SendKeys "{-}", True
Application.SendKeys "{TAB}", True
Application.SendKeys "{DEL}", True
Application.SendKeys "{TAB}", True
Application.SendKeys "{DEL}", True
Application.SendKeys "{ENTER}", True
Application.SendKeys "%F", True
Application.SendKeys "C", True
Application.SendKeys "%F", True
Application.SendKeys "s", True
End if
End Sub |
|