Bonjour,

j'ai une erreur 1004 sur ce code là.
Il fonctionne très bien sous 2003; mais 2010... My godness...
Voila l'erreur :
"erreur définie par l'application ou par l'objet"
Je vous ai mit en rouge dans le code là ou le debuggeur s’arrête.

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
'On créer le diagramme pour avoir la porportion par type de dechet
Sub Creation_Diagramme(ByVal Total_dd As Double, ByVal Total_dnd As Double, ByVal Total_di As Double, ByVal Total_deee As Double)
    
    Const StrNom As String = "Répartition des déchets"
    Dim Sr As Series
     
    Application.ScreenUpdating = False
    'Pour supprimer d'abord l'éventuelle feuille graphique
    '---------------------------
    On Error Resume Next
    Application.DisplayAlerts = False
    ThisWorkbook.Sheets(StrNom).Delete
    Application.DisplayAlerts = True
    On Error GoTo 0
    '---------------------------
     
    With ActiveWorkbook.Charts.Add
        .Name = StrNom
        .ChartType = xlPie
        
        If .SeriesCollection.Count = 0 Then
            Set Sr = .SeriesCollection.NewSeries
        Else
            Set Sr = .SeriesCollection(1)
        End If
        
        'On ajoute les pourcentage et le nom des catégories
        .ApplyDataLabels ShowPercentage:=True, ShowCategoryName:=True
            
        With Sr
            'On renseigne les valeurs du graphique et on colorise le diagramme
            .XValues = Array("DD", "DND", "DI", "DEEE")
            .Values = Array(Total_dd, Total_dnd, Total_di, Total_deee)
            .Name = StrNom
            .Points(1).Interior.ColorIndex = DECHET_DANGEREUX
            .Points(2).Interior.ColorIndex = DECHET_NON_DANGEREUX
            .Points(3).Interior.ColorIndex = DECHET_INERTE
            .Points(4).Interior.ColorIndex = DECHET_ELECTRIQUE
            
            'On supprime les Label qui sont égale à 0% ou inexistant
            If (Total_dd = 0 And Not IsNull(Total_dd)) Then .Points(1).DataLabel.Delete
            If (Total_dnd = 0 And Not IsNull(Total_dd)) Then .Points(2).DataLabel.Delete
            If (Total_di = 0 And Not IsNull(Total_dd)) Then .Points(3).DataLabel.Delete
            If (Total_deee = 0 And Not IsNull(Total_dd)) Then .Points(4).DataLabel.Delete
        End With
        
    End With
End Sub
PS: Les fonctions du 2007 fonctionne sous 2010 ? Ou je vais devoir adapté le logiciel à 2007-2010-2013 et réécrire une partie des fonctions à chaque fois ?