Sub fdgdfs()
Application.ScreenUpdating = 0
Application.DisplayAlerts = 0
Dim fs, fold, fls, fl
Set fs = CreateObject("Scripting.FileSystemObject")
Set fold = fs.getfolder(ThisWorkbook.Path) 'folderpath指文件夹路径,string型,实践中自行替换
Set fls = fold.Files
For Each fl In fls
If InStr(fl.Name, ".xls") <> 0 And Right(fl.Name, 3) = "xls" Then '避免打开非Excel文
Workbooks.Open (ThisWorkbook.Path & "\" & fl.Name)
ActiveWorkbook.SaveAs Filename:= _
ThisWorkbook.Path & "\" & Left(fl.Name, Len(fl.Name) - 4) & ".xlsx", FileFormat:= _
xlOpenXMLWorkbook, CreateBackup:=False
ActiveWorkbook.Close
End If
Next
Application.ScreenUpdating = 1
Application.DisplayAlerts = 1
End Sub
代码好了刚才程序忘记使用红色部分了,你生成的文件全在我的文档里面!!!