首页 > 其他 > 详细

用VB把xlsx转换为xls

时间:2016-08-01 12:17:40      阅读:735      评论:0      收藏:0      [点我收藏+]

Sub Test()
Dim wb As Workbook, mPath As String, f As String
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
If Workbooks.Count > 1 Then MsgBox "关闭其他工作簿后再试!": Exit Sub
MsgBox "选择.xlsx文件所在的文件夹!"
With Application.FileDialog(msoFileDialogFolderPicker)
.Show
.AllowMultiSelect = False
If .SelectedItems.Count = 0 Then MsgBox "你放弃了操作!": Exit Sub
mPath = .SelectedItems(1)
End With
f = Dir(mPath & "\*.xlsx")
Do While f <> ""
If f <> ThisWorkbook.Name And Left(f, Len(f) - 1) <> ThisWorkbook.Name Then
Set wb = Workbooks.Open(mPath & "\" & f, , False)
wb.SaveAs Filename:=mPath & "\" & Left(f, Len(f) - 1), FileFormat:=xlExcel8
wb.Close True
Kill mPath & "\" & f
End If
f = Dir
Loop
Application.DisplayAlerts = True
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
MsgBox "处理完成!"
End Sub

用VB把xlsx转换为xls

原文:http://www.cnblogs.com/mahocon/p/5724901.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!