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
|
Public Function MakeGraphe(FichierCSV As String, Repertoire As String, epaisseur As Integer) As Boolean
Dim reussis As Boolean
Dim a As Byte
Dim nomcourt As String
Dim temp As Variant
Dim classeur As Workbook, graphi As Chart
nomcourt = Mid(FichierCSV, InStrRev(FichierCSV, "\") + 1)
On Error Resume Next
Workbooks.OpenText Filename:=FichierCSV, origin:=xlWindows, DataType:=xlDelimited, ConsecutiveDelimiter:=True, Tab:=True, semicolon:=True, comma:=True, Space:=True
reussis = Err.Number = 0
On Error GoTo 0
If reussis Then
Set classeur = Workbooks(nomcourt)
nomcourt = Left(nomcourt, Len(nomcourt) - 4)
classeur.Sheets(nomcourt).Rows("2:3").Delete Shift:=xlUp
Set graphi = classeur.Charts.Add
With graphi
For Each temp In .SeriesCollection
temp.Delete
Next
.Location Where:=xlLocationAsNewSheet, Name:="Graph" & Mid(nomcourt, 6)
.ChartType = xlXYScatter
.HasLegend = True
.HasTitle = True
For a = 1 To 3
.SeriesCollection.NewSeries
.SeriesCollection(a).XValues = "='" & nomcourt & "'!A:A"
.SeriesCollection(a).Values = "='" & nomcourt & "'!" & Chr(77 + a) & ":" & Chr(77 + a)
.SeriesCollection(a).Name = "='" & nomcourt & "'!" & Chr(77 + a) & "1"
Next
.Axes(xlValue).MinimumScale = epaisseur - 75
.Axes(xlValue).MaximumScale = epaisseur + 75
.Axes(xlValue).MajorUnit = 10
.Axes(xlCategory).MinimumScale = 35
.Axes(xlCategory).MaximumScale = 995
.Axes(xlCategory).MajorUnit = 40
For a = 1 To 3
With .SeriesCollection(a)
.MarkerStyle = a
.MarkerSize = 2
End With
Next
.ChartTitle.Characters.Text = nomcourt
.ChartTitle.Characters.Font.FontStyle = "Bold"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "mm"
.Axes(xlValue).AxisTitle.Orientation = xlHorizontal
.Axes(xlValue, xlPrimary).AxisTitle.Characters(1, 1).Font.Name = "Symbol"
.ChartTitle.Top = 8
.Axes(xlValue).AxisTitle.Left = 29
.Axes(xlValue).AxisTitle.Top = 4.908
With .PlotArea
.Left = 1
.Top = 1
.Width = 680
.Height = 490
End With
With .Legend
.Left = 606.282
.Top = 5
End With
On Error Resume Next
Kill Repertoire & nomcourt & ".png"
On Error GoTo 0
On Error Resume Next
.Export Filename:=Repertoire & nomcourt & ".png", FilterName:="PNG"
reussis = Err.Number = 0
On Error GoTo 0
End With
Set graphi = Nothing
classeur.Close (False)
Set classeur = Nothing
End If
MakeGraphe = reussis
End Function |
Partager