[VBA-E] fonction DoEvents ?
Bonjour,
Grace à l'aide d'une personne du forum (que je remercie encore), j'ai pu aboutir à ce code qui permet de faire évoluer la mise en forme des courbes d'un graphe :
Code:
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
|
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Sub Macro1()
Dim graph As Chart
Dim j As Single
Set graph = Feuil1.ChartObjects("Graphique 3").Chart
For j = 1 To 240 'ttes courbes désactivées
graph.SeriesCollection(j).Border.LineStyle = xlNone
graph.SeriesCollection(j).MarkerBackgroundColorIndex = xlNone
graph.SeriesCollection(j).MarkerForegroundColorIndex = xlNone
Next j
For j = 1 To 240 'courbe active
graph.SeriesCollection(j).Border.ColorIndex = 11
graph.SeriesCollection(j).Border.Weight = xlThick
graph.SeriesCollection(j).MarkerBackgroundColorIndex = 11
graph.SeriesCollection(j).MarkerForegroundColorIndex = 11
If j > 1 Then 'on désactive courbe précédente
graph.SeriesCollection(j - 1).Border.LineStyle = xlNone
graph.SeriesCollection(j - 1).MarkerBackgroundColorIndex = xlNone
graph.SeriesCollection(j - 1).MarkerForegroundColorIndex = xlNone
End If
Sleep (100)
DoEvents 'exécution des commandes
Next j
End Sub |
Je ne comprends pas le rôle de la fonction DoEvents ici : si on ne la met pas, les mises en forme des courbes ne se font pas.
Pourquoi ? (J'ai bien sur regarder l'aide sur la fonction mais ça ne m'aide pas justement).