[求助] 如何l利用vba,批量修改文件夹下所有工作簿中的VAB宏程序
附件位置:http://club.excelhome.net/thread-1057608-1-1.html 展开
1.信任对于VB项目的访问
Sub SetAllowableVbe()
On Error Resume Next
Dim Chgset As Boolean
'陷阱测试,VBProject.Protection在这儿并无实际的意义
Debug.Print ThisWorkbook.VBProject.Protection
If Err.Number = 1004 Then
Err.Clear
Application.SendKeys "%TMS%T%V{ENTER}"
Chgset = True
DoEvents
End If
End If
End If
'要执行的操作....
'.....
'操作完成后还原操作前的状态
If Chgset Then Application.SendKeys "%TMS%T%V{ENTER}"
End Sub
2.操作密码工程
Sub AllowPass()
Dim pw$
pw = "SH"
If ThisWorkbook.VBProject.Protection = vbext_pp_locked Then
Application.VBE.CommandBars(1).Controls("工具(T)").Controls("VBAProject 属性(&E)...").Execute
Application.SendKeys pw & "{ENTER}{ENTER}"
DoEvents
End If
'要执行的操作….
'.....
End Sub