Sub ConvertToXlsx() 'Updateby Extendoffice Dim strPath As String Dim strFile As String Dim xWbk As Workbook Dim xSFD, xRFD As FileDialog Dim xSPath As String Dim xRPath As String Set xSFD = Application.FileDialog(msoFileDialogFolderPicker) With xSFD .Title = "请选择要转换的xls文件所在的文件夹:" .InitialFileName = "C:\" End With If xSFD.Show <> -1 Then Exit Sub xSPath = xSFD.SelectedItems.Item(1) Set xRFD = Application.FileDialog(msoFileDialogFolderPicker) With xRFD .Title = "请选择转换成xlsx后要保存的文件夹:" .InitialFileName = "C:\" End With If xRFD.Show <> -1 Then Exit Sub xRPath = xRFD.SelectedItems.Item(1) & "\" strPath = xSPath & "\" strFile = Dir(strPath & "*.xls") Application.ScreenUpdating = False Application.DisplayAlerts = False Do While strFile <> "" If Right(strFile, 3) = "xls" Then Set xWbk = Workbooks.Open(Filename:=strPath & strFile) xWbk.SaveAs Filename:=xRPath & strFile & "x", _ FileFormat:=xlOpenXMLWorkbook xWbk.Close SaveChanges:=False End If strFile = Dir Loop Application.DisplayAlerts = True Application.ScreenUpdating = True End Sub
评论已关闭