Bonjour,

Je ne parviens pas a débuguer la macro ci-dessous.

Pour information, elle a fonctionné pendant plusieurs années et depuis peu j'ai des instructions qui plantent.
Ici la méthode SaveAs qui échoue.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
ActiveWorkbook.SaveAs Filename:=chemin, FileFormat:=xlCSV, Local:=True
J'utilise actuellement Excel Microsoft 365 Version 2406.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
Sub Generer_fichier()
    
    If Not IsEmpty(ActiveWorkbook.Worksheets("Configuration").Range("D9")) And Not IsEmpty(ActiveWorkbook.Worksheets("INPUT_DEVIS").Range("C2")) And Not IsEmpty(ActiveWorkbook.Worksheets("INPUT_RAMES").Range("B8")) Then
    
        ActiveWorkbook.Save
        ActiveWorkbook.RefreshAll
        
        If IsEmpty(ActiveWorkbook.Worksheets("CSV_LIGNES_DEVIS_RAMES").Range("A2")) Then
            MsgBox "Les prestations n'ont pas été ventilées par type de rame"
        Else
            Dim dossier$, fichier$, chemin$
            
            With Application.FileDialog(msoFileDialogFolderPicker)
                If .Show <> 0 Then dossier = .SelectedItems(1) & "\" Else Exit Sub
            End With
            
            '---------------Debut export rames----------------------
            fichier = "1 - Export_rames_" & ActiveWorkbook.Worksheets("Configuration").Range("D9").Value & "_" & ActiveWorkbook.Worksheets("Configuration").Range("D11").Value & "_" & Format(Now, "yyyymmdd")

            chemin = dossier & fichier
            If Dir(chemin) <> "" Then
                If MsgBox("Le fichier existe déjà ! Voulez-vous le remplacer ?", vbYesNo + vbExclamation, "Demande de confirmation") <> vbYes Then Exit Sub
            End If
            
            Application.ScreenUpdating = False
            Application.DisplayAlerts = False
            ThisWorkbook.Worksheets("CSV_RAMES").Visible = True
            ThisWorkbook.Worksheets("CSV_RAMES").Copy
            ActiveWorkbook.SaveAs Filename:=chemin, FileFormat:=xlCSV, Local:=True
            ActiveWorkbook.Close
            Application.DisplayAlerts = True
            ThisWorkbook.Worksheets("CSV_RAMES").Visible = False
            Application.ScreenUpdating = True
            MsgBox "Votre fichier a été exporté " + fichier, , "EXPORT RAMES"
            '---------------Fin export rames----------------------
        End If
    Else
        If IsEmpty(ActiveWorkbook.Worksheets("Configuration").Range("D9")) Then
            MsgBox "L'affaire n'a pas été sélectionnée"
        Else
            If IsEmpty(ActiveWorkbook.Worksheets("INPUT_DEVIS").Range("C2")) Then
                MsgBox "Le devis n'a pas été importé"
            Else
                MsgBox "Les rames n'ont pas été saisies"
            End If
        End If
    End If
    
End Sub
Merci d'avance pour votre aide.

Bien cordialement