Sub Camembert()
Dim plage As Range
Dim Chemin As String
Dim x, i As Integer
Dim Graph As ChartObject
Dim t As Double
On Error Resume Next
Set Graph = Sheets("Feuil1").ChartObjects.Add(227, 20, 190, 160)
i = 1
For x = 1 To 52
i = i + 1
Set plage = Sheets("Feuil1").Range("B1:F1," & "B" & i & ":" & "F" & i)
ActiveSheet.ChartObjects(1).Activate
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "Poduction Secteur " & ActiveSheet.Range("A" & i)
End With
With ActiveChart.ChartTitle.Characters
.Font.Size = 10
End With
With ActiveChart.SeriesCollection(1).Points(1).Format.Fill
.Visible = msoTrue
.ForeColor.RGB = RGB(205, 104, 155)
.Transparency = 0
.Solid
End With
With ActiveChart.SeriesCollection(1).Points(2).Format.Fill
.Visible = msoTrue
.ForeColor.RGB = RGB(153, 51, 102)
.Transparency = 0
.Solid
End With
With ActiveChart.SeriesCollection(1).Points(3).Format.Fill
.Visible = msoTrue
.ForeColor.RGB = RGB(255, 255, 153)
.Transparency = 0
.Solid
End With
With ActiveChart.SeriesCollection(1).Points(4).Format.Fill
.Visible = msoTrue
.ForeColor.RGB = RGB(0, 102, 204)
.Transparency = 0
.Solid
End With
With ActiveChart.SeriesCollection(1).Points(5).Format.Fill
.Visible = msoTrue
.ForeColor.RGB = RGB(255, 255, 204)
.Transparency = 0
.Solid
End With
With ActiveChart.SeriesCollection(1).Points(6).Format.Fill
.Visible = msoTrue
.ForeColor.RGB = RGB(255, 0, 0)
.Transparency = 0
.Solid
End With
ActiveSheet.ChartObjects(1).Name = ActiveSheet.Range("A" & i)
nom = "Poduction Secteur " & ActiveSheet.Range("A" & i) & ".gif"
ActiveChart.ChartArea.Select
ActiveChart.ChartType = xlDoughnut
ActiveChart.SetSourceData Source:=plage, PlotBy:=xlRows
With ActiveSheet.ChartObjects(1)
With .Border
.Weight = xlThick
.LineStyle = xlAutomatic
.ColorIndex = xlNone
End With
End With
t = Timer + 0.8: Do Until Timer > t: DoEvents: Loop
'ActiveChart.Legend.Delete
Chemin = ThisWorkbook.Path & "\Images\"
Call Creer_PDF
ActiveChart.Export Chemin & nom, "GIF"
Next x
End Sub
Sub Creer_PDF()
Dim Fname, Chemin As String
Chemin = ThisWorkbook.Path & "\PDF\"
Fname = Chemin & Application.PathSeparator
Fname = Fname & "Poduction Secteur " & ActiveSheet.ChartObjects(1).Name & ".pdf"
ActiveChart.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=Fname, _
Quality:=xlQualityStandard, _
includedocproperties:=True, _
ignoreprintareas:=False, _
openafterpublish:=False
End Sub