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 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
|
Sub Tracer()
Dim Fe As Worksheet
Dim Fleche As Shape
Dim Trait As Shape
Dim Texte As Shape
Dim Tbl(1 To 2, 1 To 8)
Dim DifDate As Long
Dim I As Long
Dim HautFleche As Integer
Dim GaucheFleche As Long
Dim EpaisFleche As Integer
Dim HautTrait As Integer
Dim GaucheTrait As Long
Dim EpaisTrait As Integer
Dim Coeff As Single
GaucheFleche = 50
HautFleche = 200
EpaisFleche = 10
EpaisTrait = 1
HautTrait = 30
Coeff = 4 'coefficient pour agrandir la zone dans le cas où les Labels se chevauchent
Set Fe = ActiveSheet
'supprime tous les Shapes avant de créer le graphique
Effacer
'tableau à deux dimensions dont la première contient les segments et la seconde les dates
With Worksheets("ADD_INFOS")
Tbl(1, 1) = "PO Date": Tbl(2, 1) = CDate(.[C9])
Tbl(1, 2) = "Deliv Date OTD1": Tbl(2, 2) = CDate(.[H8])
Tbl(1, 3) = "Deliv Target Date": Tbl(2, 3) = CDate(.[H6])
Tbl(1, 4) = "Last Rejection Date": Tbl(2, 4) = CDate(.[H11])
Tbl(1, 5) = "Deliv Date OTD2": Tbl(2, 5) = CDate(.[H13])
Tbl(1, 6) = "Deliv note Test": Tbl(2, 6) = CDate(.[F21])
Tbl(1, 7) = "Deliv note A": Tbl(2, 7) = CDate(.[F22])
Tbl(1, 8) = "Good Receipt": Tbl(2, 8) = CDate(.[E30])
End With
'durée du projet multiplié par le coefficient afin d'éviter le chevauchement des Labels
DifDate = (Tbl(2, UBound(Tbl, 2)) - Tbl(2, LBound(Tbl, 2))) * Coeff
'flèche horizontale
Set Fleche = Fe.Shapes.AddShape(msoShapeRightArrow, GaucheFleche, HautFleche, DifDate, EpaisFleche)
'pose des traits verticaux et des zones de texte (Label)
For I = 1 To UBound(Tbl, 2) - 1
'traits verticaux
GaucheTrait = GaucheTrait + (Tbl(2, I + 1) - Tbl(2, I)) * Coeff 'doit aussi être multiplié par le coefficient
'58 correspond à une flèche double pointant vers le haut et le bas !
Set Trait = Fe.Shapes.AddShape(58, GaucheTrait, (HautFleche + EpaisFleche / 2) - HautTrait / 2, EpaisTrait, HautTrait)
'zone de texte pour les dates
Set Texte = Fe.Shapes.AddLabel(msoTextOrientationHorizontal, 1, (HautFleche + EpaisFleche / 2) + HautTrait / 2 + 10, 100, 20)
'sans marge, et transparent pour le fond et les bordures
With Texte
With .TextFrame
.Orientation = msoTextOrientationVertical
.Characters.Text = Tbl(2, I)
.AutoSize = True
.MarginLeft = 0
.MarginRight = 0
.MarginTop = 0
.MarginBottom = 0
End With
.Rotation = 180
.Left = GaucheTrait - (.Width / 2 + EpaisTrait / 2)
.Top = (HautFleche + EpaisFleche / 2) + HautTrait / 2 '+ 10
.Fill.Transparency = 1
.Line.Transparency = 1
End With
'zone de texte pour les étapes
Set Texte = Fe.Shapes.AddLabel(msoTextOrientationHorizontal, 1, (HautFleche - EpaisFleche / 2) - HautTrait, 100, 20)
'sans marge, et transparent pour le fond et les bordures
With Texte
With .TextFrame
.Orientation = msoTextOrientationVertical
.Characters.Text = Tbl(1, I)
.AutoSize = True
.MarginLeft = 0
.MarginRight = 0
.MarginTop = 0
.MarginBottom = 0
End With
.Rotation = 180
.Left = GaucheTrait - (.Width / 2 + EpaisTrait / 2)
.Top = (HautFleche + EpaisFleche / 2) - .Height - HautTrait + 10
.Fill.Transparency = 1
.Line.Transparency = 1
End With
Next I
'si le délai est dépassé, il ne sert plus à rien de matérialisé la date du jour sur le graphique
If Date > Tbl(2, UBound(Tbl, 2)) Then Exit Sub
'défini la position du trait vertical de la date d'aujourd'hui
GaucheTrait = GaucheFleche + (Date - Tbl(2, 1)) * Coeff 'doit aussi être multiplié par le coefficient
'58 correspond à une flèche double pointant vers le haut et le bas !
Set Trait = Fe.Shapes.AddShape(58, GaucheTrait, (HautFleche + EpaisFleche / 2) - HautTrait / 2, EpaisTrait, HautTrait)
'colore le trait symbolisant la date d'aujourd'hui en rouge
Trait.Fill.ForeColor.RGB = RGB(255, 0, 0)
Trait.Line.ForeColor.RGB = RGB(255, 0, 0)
'aujourd'hui
Set Texte = Fe.Shapes.AddLabel(msoTextOrientationHorizontal, 1, (HautFleche - EpaisFleche / 2) - HautTrait, 100, 20)
'sans marge, et transparent pour le fond et les bordures
With Texte
With .TextFrame
.Orientation = msoTextOrientationVertical
.Characters.Text = "Aujourd'hui"
.AutoSize = True
.MarginLeft = 0
.MarginRight = 0
.MarginTop = 0
.MarginBottom = 0
End With
.Rotation = 180
.Left = GaucheTrait - (.Width / 2 + EpaisTrait / 2)
.Top = (HautFleche + EpaisFleche / 2) - .Height - HautTrait + 10
.Fill.Transparency = 1
.Line.Transparency = 1
End With
Set Texte = Fe.Shapes.AddLabel(msoTextOrientationHorizontal, 1, (HautFleche + EpaisFleche / 2) + HautTrait / 2 + 10, 100, 20)
'sans marge, et transparent pour le fond et les bordures
With Texte
With .TextFrame
.Orientation = msoTextOrientationVertical
.Characters.Text = Date
.AutoSize = True
.MarginLeft = 0
.MarginRight = 0
.MarginTop = 0
.MarginBottom = 0
End With
.Rotation = 180
.Left = GaucheTrait - (.Width / 2 + EpaisTrait / 2)
.Top = (HautFleche + EpaisFleche / 2) + HautTrait / 2
.Fill.Transparency = 1
.Line.Transparency = 1
End With
End Sub |
Partager