- 在批量CSV文件夹中新建一个EXCEL文件并打开,在打开的文件中点开发工具->宏,创建一个宏。
- VBA通用窗体中输入下面代码:
Sub 转换()
Application.ScreenUpdating = False
pth = ThisWorkbook.Path & "\"
flnm = Dir(pth & "*.csv")
Do While Len(flnm) > 0
With Workbooks.Open(pth & flnm, ReadOnly:=True)
.SaveAs Replace("D:\myFiles\write\" & flnm, ".csv", ""), IIf(Application.Version >= 12, xlWorkbookDefault, xlWorkbookNormal)
.Close
End With
flnm = Dir
Loop
End Sub
D:\myFiles\write\是输出路径
- 再点击工具栏中的运行-运行子过程/用户窗体)新的表格会自动保存
网友评论