第1个回答 2010-04-30
工具-宏-Visual Bsaic编辑器
将下段代码复制运行即可。
注意:
1.把要加密的文件放在同一个文件夹下,如g:\123
2.代码中.LookIn = "g:\123"双引号内蓉工作簿路径,按照你放置的位置填写
3.代码中ActWb.Password = "YourPassowrd" '双引号中为密码,按你想要设定 的填写
'--------------------------
Sub BulkEncryption()
Dim ActWb, ThisWb, Wb As Workbook
Dim MyWb
Set ThisWb = ThisWorkbook
Set ActWb = ActiveWorkbook
Application.ScreenUpdating = False
With Application.FileSearch
.FileType = msoFileTypeExcelWorkbooks
.LookIn = "g:\123" '此处为工作簿路径
.Execute msoSortByFileName
For Each MyWb In .FoundFiles
If MyWb <> ThisWb.FullName Then
Set ActWb = Workbooks.Open(MyWb)
ActWb.Password = "Passowrd" '此处为密码
ActWb.Save
ActWb.Close
End If
Next
End With
Application.ScreenUpdating = True
End Sub
'------------------------------------
祝你成功!本回答被提问者采纳