Sub Conversion_XLSX_vers_ODS()
Dim ODS_Nom$, XLSX_Nom$, StrPath$
Dim oWorkbook As Workbook, fDialog As FileDialog
Set fDialog = Application.FileDialog(msoFileDialogFolderPicker)
With fDialog
.Title = "Sélectionner le dossier contenant les fichiers ODS"
.AllowMultiSelect = False
.InitialView = msoFileDialogViewList
If .Show <> -1 Then
MsgBox "Convertion annulée", , "Avertissement"
Exit Sub
End If
StrPath = fDialog.SelectedItems.Item(1)
If Right(StrPath, 1) <> "\" Then StrPath = StrPath + "\"
End With
If Left(StrPath, 1) = Chr(34) Then
StrPath = Mid(StrPath, 2, Len(StrPath) - 2)
End If
XLSX_Nom = Dir$(StrPath & "*.xlsx")
While Len(XLSX_Nom) <> 0
Set oWorkbook = Workbooks.Open(StrPath & XLSX_Nom)
ODS_Nom = StrPath & Left(oWorkbook.Name, InStrRev(oWorkbook.Name, ".") - 1)
oWorkbook.SaveAs Filename:=ODS_Nom & ".ods", FileFormat:=xlOpenDocumentSpreadsheet
oWorkbook.Close False
XLSX_Nom = Dir$()
Wend
MsgBox "La conversion est terminée", , "XLSX vers ODS"
Exit Sub
End Sub