Sub Conversion_Vers_XLSX()
Dim FSO As Object, fFile As Object, fFolder As Object, strConversionPath$, wkbConvert As Workbook
' Choix du dossier
With Application.FileDialog(msoFileDialogFolderPicker)
.AllowMultiSelect = False: .Show: strConversionPath = .SelectedItems(1)
End With
With CreateObject("Scripting.FileSystemObject")
If .FolderExists(strConversionPath) Then
Set fFolder = .GetFolder(strConversionPath)
' Boucle sur le dossier pour chercher *.xlsm ou *.xlsb
For Each fFile In fFolder.Files
If Right(fFile.Name, 5) = ".xlsm" Or Right(fFile.Name, 5) = ".xlsb" Then
Application.DisplayAlerts = False
Set wkbConvert = Workbooks.Open(fFile.Path)
' Sauvegarde en *.xlsx
wkbConvert.SaveAs .BuildPath(fFile.ParentFolder, Left(fFile.Name, InStrRev(fFile.Name, ".") - 1)) & ".xlsx", FileFormat:=51
wkbConvert.Close SaveChanges:=False
'Suppresion du fichier original
fFile.Delete Force:=True
Application.DisplayAlerts = True
End If
Next fFile
End If
End With
'adapté de [N.Perkins|281212|(0)(0)29166]
End Sub