Sub aaa() Dim objshell As Object, objfolder As Object Dim myPath$, myFile$, SourceFile$, DestinationFile$ Dim i As Byte Dim arr '得到合并路径 Set objshell = CreateObject("Shell.Application") Set objfolder = objshell.BrowseForFolder(0, "选择文件夹", 0, 0) If objfolder Is Nothing Then End Else myPath = objfolder.self.Path & "\" End If Set objfolder = Nothing Set objshell = Nothing Application.ScreenUpdating = False Application.DisplayAlerts = False arr = [{"前期","中期","后期","地市"}] '循环所有工作簿 myFile = Dir(myPath & "*.doc") Do While myFile <> "" For i = 1 To UBound(arr) If myFile Like "*" & arr(i) & "*" Then '移动文件 SourceFile = myPath & myFile DestinationFile = myPath & arr(i) & "\" & myFile FileCopy SourceFile, DestinationFile Kill myPath & myFile Exit For End If Next i myFile = Dir Loop Application.DisplayAlerts = True Application.ScreenUpdating = True MsgBox "完成" End Sub |