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
|
Option Explicit
Sub TrTest2()
Dim feuilleData, fTr As Worksheet
Dim Emplacement As Range
Dim i, Index, NbFiches, NbPoints As Integer
Dim NomFichier As String
Dim MonGraph As Shape
Set feuilleData = ActiveWorkbook.Sheets("Selection")
Set fTr = ActiveWorkbook.Sheets("Trame")
NbFiches = 2 ' nombre de passages dans la boucel
NbPoints = 8 ' nombre de points par série
For Index = 1 To NbFiches
'---------------------------------------------------------------------------------------------
' Calcul test des données à tracer
For i = 1 To NbPoints
feuilleData.Cells(2, i) = i / NbPoints
feuilleData.Cells(3, i) = Index
Next i
'---------------------------------------------------------------------------------------------
' intialisation de la feuille de destination
fTr.Activate
Cells.Select
Selection.Delete Shift:=xlUp
'----------------------------------------------------------------------------------------------
' emplacement
With fTr
.Cells(1, 4) = "Numéro : "
.Cells(1, 5) = Index
Set Emplacement = .Range("A9:H28") ' emplacement où doit arriver le graphique sur Trame
Set MonGraph = .Shapes.AddChart2(XlChartType:=xlRadarMarkers, Left:=Emplacement.Left, Top:=Emplacement.Top, Height:=Emplacement.Height, Width:=Emplacement.Width)
.ChartObjects(1).Name = "RadarTest"
End With
With MonGraph.Chart
.SetSourceData Source:=Range("Selection!$A$1:$H$3"), PlotBy:=xlRows
.FullSeriesCollection(1).Name = "=""année 1""" ' série 1
.FullSeriesCollection(2).Name = "=""année 2""" ' série 2
End With
'----------------------------------------------------------------------------------------------
' enregistrement
NomFichier = "D:\Export\FichierTest" & Index
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:=NomFichier & ".pdf", _
Quality:=xlQualityStandard, IncludeDocProperties:=True, _
IgnorePrintAreas:=False, From:=1, To:=1, OpenAfterPublish:=False
Next Index
End Sub |
Partager