如何将文件夹内的所有的excel的csv文件另存为xls文件?
我经常有好多excel文件的csv文件,需要转化成xls文件.有没有大神知道怎么一键把所有的csv文件一下子都另存为xls文件啊?大神...救命.....求程序........
我经常有好多excel文件的csv文件,需要转化成xls文件.有没有大神知道怎么一键把所有的csv文件一下子都另存为xls文件啊?大神...救命.....
求程序..... 展开
求程序..... 展开
2个回答
展开全部
Sub test()
Dim fn As String, mPath As String, wb As Workbook
If Workbooks.Count > 1 Then MsgBox "关闭其他文件后重试!": Exit Sub
With Application.FileDialog(msoFileDialogFolderPicker)
.Title = "-----------------------选择csv文件所在的文件夹---------------------"
.AllowMultiSelect = False
.Show
If .SelectedItems.Count = 0 Then MsgBox "你放弃了操作!": Exit Sub
mPath = .SelectedItems(1)
End With
Application.ScreenUpdating = False
Application.DisplayAlerts = False
fn = Dir(mPath & "\*.csv")
Do While fn <> ""
Set wb = Workbooks.Open(mPath & "\" & fn, , False)
wb.SaveAs mPath & "\" & Left(fn, Len(fn) - 3) & "xls", xlExcel8
wb.Close 0
Kill mPath & "\" & fn
fn = Dir
Loop
Application.DisplayAlerts = True
Application.ScreenUpdating = True
MsgBox "处理完成!"
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询