是否可以编辑如下内容:
Sub password()
Dim wb As Workbook
Dim StrPassword As String, strFile As String, strFolder As String
StrPassword = "xxxxxxx"
strFolder = "C:\"
strFile = Dir(strFolder & "*Report.xlsx", vbNormal)
FastMode True
While strFile <> ""
Set wb = Workbooks.Open(filename:=strFolder & strFile)
With wb
.password = StrPassword
.SaveAs filename:=wb.FullName, password:=StrPassword
.Close
End With
strFile = Dir()
Wend
FastMode False
End Sub
Public Sub FastMode(ByVal Toggle As Boolean)
Application.ScreenUpdating = Not Toggle
Application.EnableEvents = Not Toggle
Application.DisplayAlerts = Not Toggle
Application.EnableAnimations = Not Toggle
Application.DisplayStatusBar = Not Toggle
Application.PrintCommunication = Not Toggle
Application.Calculation = IIf(Toggle, xlCalculationManual, xlCalculationAutomatic)
End Sub
我想知道是否有一种方法可以分配路径目录并消除打开密码保护-关闭每个文件的需要?我可以说,执行该过程需要执行代码的时间的99%。
有没有一种方法可以批量添加密码,而无需实际执行太多操作来分别打开/关闭文件?
密码保护2500个文件大约需要20分钟,这还不错,但是我想知道它是否可以更快地完成?