Enregistrer les fichiers

Bonjour,

J'ai fait un code pour lister les fichiers d'un dossier sur Excel quand j'appuie sur un bouton Ce code fonctionne. A partir de la, j'aimerais dire à mon code d'ouvrir chacun des fichiers du dossier (les fichiers sont au format .ods), de les enregistrer sous au format xlsx. Est ce possible ? Merci d'avance !

slt jul997,

oui c'est possible.

Bonne journée

Merci pour ta réponse !

Mais du coup comment je dois m'y prendre?

Sachant que lorsque j'ouvre Excel et que je fais fichier puis ouvrir et que je selectionne un des fichiers au format ods, j'ai un message d'erreur qui me dit que le format ou l'extension du fichier n'est pas valide....

Merci!

Re,

poste ton code ici afin de pouvoir t'aider

Sub ListingFichiers()

Dim Rep As String, Fichier As String

Dim i As Integer

Rep = "F:\Documents vannes sous LibreOffice\Test"

Fichier = Dir(Rep)

Do While Fichier <> ""

i = i + 1

Sheets("Feuil1").Range("A" & i) = Fichier

Fichier = Dir

Loop

End Sub

cela le sert uniquement à lister me fichiers sur Excel

Re,

voici un exemple qui fonctionne trés bien. à adapter.....

Sub SaveODSToXLSX()

Dim StrFilename As String
Dim StrDocName As String
Dim StrPath As String
Dim oWorkbook As Workbook
Dim fDialog As FileDialog
Dim intPos As Integer
MsgBox "Please select the folder which contains the files for convert", , ""
Set fDialog = Application.FileGialog(msoFileDialogFolderPicker)
With fDialog
    .Title = "Select folder and click OK"
    .AllowMultiSelect = False
    .InitialView = msoFileDialogViewList
    If .Show <> -1 Then
        MsgBox "Cancelled By User", , "List Folder Contents"
        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
StrFilename = Dir$(StrPath & "*.ods")
While Len(StrFilename <> 0)
    Set oWorkbook = Workbooks.Open(StrPath & StrFilename)
    StrDocname = ActiveWorkbook.Fullname
    intPos = InStrRev(StrDocName, ".")
    StrFocName = Left(StrDocName, intPos - 1)
    StrDocName = StrDocName & ".xlsx"
    oWorkbook.SaveAs Filename:=StrDocName, FileFormat:=51
    oWorkbook.Close savechanges:=wdDoNotSaveChanges
    StrFilename = Dir$()
Wend
MsgBox "Conversion is completed", , "ODS to XLSX"
Exit Sub
End Sub

Merci beaucoup,

Je l'ai essayé et j'ai une erreur de compilation, il me dit "Variable requise, impossible de l'affecter à cette expression" et c'est le <> qui est surligné.. Merci !

Re,

deuxième essai et pas de troisième

Sub SaveODSToXLSX()

Dim StrFilename As String
Dim StrDocName As String
Dim StrPath As String
Dim obook As Workbook
Dim fDialog As FileDialog
Dim intPos As Integer
Application.ScreenUpdating = False
MsgBox "Please select the folder which contains the files for convert", , ""
Set fDialog = Application.FileDialog(msoFileDialogFolderPicker)
With fDialog
    .Title = "Select folder and click OK"
    .AllowMultiSelect = False
    .InitialView = msoFileDialogViewList
    If .Show <> -1 Then
        MsgBox "Cancelled By User", , "List Folder Contents"
        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
StrFilename = Dir$(StrPath & "*.ods")
While Len(StrFilename) <> 0
    Set obook = Application.Workbooks.Open(Filename:=StrPath & StrFilename, CorruptLoad:=xlRepairFile)
    StrDocName = ActiveWorkbook.FullName
    intPos = InStrRev(StrDocName, ".")
    StrFocName = Left(StrDocName, intPos - 1)
    StrDocName = StrDocName & ".xlsx"
    obook.SaveAs Filename:=StrDocName, FileFormat:=51
    obook.Close savechanges:=wdDoNotSaveChanges
    StrFilename = Dir$()
Wend
MsgBox "Conversion is completed", , "ODS to XLSX"
Exit Sub
End Sub
Rechercher des sujets similaires à "enregistrer fichiers"