|
发表于 2017-7-10 16:40
|
显示全部楼层
本楼为最佳答案
- Private Sub CommandButton1_Click()
- Dim fs, f, f1, fc, s, name1, name2
- Application.DisplayAlerts = False
- Application.ScreenUpdating = False
- Set fs = CreateObject("Scripting.FileSystemObject")
- pth = ThisWorkbook.Path & ""
- AA = ThisWorkbook.ActiveSheet.Cells(1, 1)
- Set f = fs.GetFolder(pth)
- Set fc = f.Files
- MkDir pth & "New"
- For Each f1 In fc
- If f1.Name Like "*.xlsx" Then
- name1 = Split(f1.Name, ".")(0)
- name2 = name1 + AA
- Workbooks.Open f1
- With ActiveWorkbook
- .SaveAs pth & "New" & name2 & ".xlsx"
- .Close
- Kill f1
- End With
- End If
- Next
- Application.DisplayAlerts = True
- Application.ScreenUpdating = True
- End Sub
复制代码 |
|