Bonjour,

J'essaye d'appliquer une mise en page automatique pour un tableau croisé dynamique mais j'ai un souci

Le code fonctionne et fait ce que je lui demande, mais il fait planter excel quand il a finit de tourner

Il va bien jusqu'a la msgbox en fin de message, mais des que je fais ok, ensuite, excel plante
Nom : plante.png
Affichages : 70
Taille : 4,0 Ko

Ensuite il se relance et le résultat est correct

Je ne comprend pas pourquoi il plante apres la macro, et comme je n'ai pas de message d'erreur, je n'ai pas la moindre idée de ce qui lui prend

Voilà le code
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
Private Sub Worksheet_PivotTableUpdate(ByVal Target As PivotTable)
Application.EnableEvents = False
Application.ScreenUpdating = False
 
Sheets("Proportions").ChartObjects("Graphique").Activate
 
'compte combien il y a de série utilisées dans le TCD
nbserie = ActiveChart.SeriesCollection.Count
 
'on passe les séries une a une
For i = 1 To nbserie
    'met toutes les bordures noires
    With ActiveChart.SeriesCollection(i).Format.Line
        .Visible = msoTrue
        .ForeColor.ObjectThemeColor = msoThemeColorText1
        .ForeColor.TintAndShade = 0
        .ForeColor.Brightness = 0
        .Transparency = 0
    End With
 
    'colorie les séries en fonction de leur nom
    If ActiveChart.SeriesCollection(i).Name = "Routines" Then
        With ActiveChart.SeriesCollection(i).Format.Fill
            .Visible = msoTrue
            .ForeColor.RGB = RGB(255, 255, 255)
            .Transparency = 0
            .Solid
        End With
    End If
 
    If ActiveChart.SeriesCollection(i).Name = "Demandes hors service" Then
        With ActiveChart.SeriesCollection(i).Format.Fill
            .Visible = msoTrue
            .ForeColor.RGB = RGB(255, 204, 204)
            .Transparency = 0
            .Solid
        End With
    End If
 
    If ActiveChart.SeriesCollection(i).Name = "Ponctuel dans le service" Then
        With ActiveChart.SeriesCollection(i).Format.Fill
            .Visible = msoTrue
            .ForeColor.RGB = RGB(255, 255, 204)
            .Transparency = 0
            .Solid
        End With
    End If
 
 
    If ActiveChart.SeriesCollection(i).Name = "Dévelopement int." Then
        With ActiveChart.SeriesCollection(i).Format.Fill
            .Visible = msoTrue
            .ForeColor.RGB = RGB(102, 255, 204)
            .Transparency = 0
            .Solid
        End With
    End If
 
 
    If ActiveChart.SeriesCollection(i).Name = "Listing prix" Then
        With ActiveChart.SeriesCollection(i).Format.Fill
            .Visible = msoTrue
            .ForeColor.RGB = RGB(204, 236, 255)
            .Transparency = 0
            .Solid
        End With
    End If
 
 
    If ActiveChart.SeriesCollection(i).Name = "Dévelopement ext." Then
        With ActiveChart.SeriesCollection(i).Format.Fill
            .Visible = msoTrue
            .ForeColor.RGB = RGB(204, 255, 102)
            .Transparency = 0
            .Solid
        End With
    End If
 
 
    If ActiveChart.SeriesCollection(i).Name = "Cours / explications" Then
        With ActiveChart.SeriesCollection(i).Format.Fill
            .Visible = msoTrue
            .ForeColor.RGB = RGB(255, 204, 102)
            .Transparency = 0
            .Solid
        End With
    End If
Next i
'on impose la dimention de la légende
ActiveChart.Legend.Height = 252.109
 
Application.ScreenUpdating = True
Application.EnableEvents = True
 
'on vérifie si on atteind bien ce point de la macro
MsgBox "ok"
 
End Sub
Est-ce que quelqu'un aurait des pistes a explorer?
Merci