我开发了一个宏来批量更新文件位置中的文件。我使用以下代码,它运行良好,但是脚本的编辑部分需要更改每个文件中的 VBA 模块才能使调用编辑宏中的更改生效。执行批量文件更新时,如何批量更新模块内容。
Sub Auto_open_change()
Dim WrkBook As Workbook
Dim StrFileName As String
Dim FileLocnStr As String
Dim LAARNmeWrkbk As String
PERNmeWrkbk = ThisWorkbook.Name
FileLocnStr = "C:\Users\gornalla\Desktop\PER Update" 'ThisWorkbook.Path
Dim StrFile As String
StrFile = Dir(FileLocnStr & "\*.xlsm")
Do While Len(StrFile) > 0
DoStuff (FileLocnStr & "\" & StrFile)
StrFile = Dir
Loop
End Sub
Private Sub DoStuff(StrFileName)
Workbooks.Open (StrFileName)
'Workbooks(StrFileName).Activate
ActiveSheet.Unprotect ("147258369")
Sheets("Property Evaluation Report").Select
ActiveSheet.Unprotect ("147258369")
Call Edit
ActiveWorkbook.RefreshAll
Sheets("Property Evaluation Report").Select
ActiveSheet.Protect Password:="147258369", DrawingObjects:=True, Contents:=True, Scenarios:=True, AllowUsingPivotTables:=True
ActiveWorkbook.Close
Application.SendKeys ("Enter")
End Sub