Bonjour,
Dans ma une macro, je crée un graphique, et dans une autre, je le redimensionne, mais mon problème c'est que je n'arrive pas a selectionner mon graphique pour le redimensionner.
La macro de création :
ActiveWindow.Visible = False
Windows("Test_graph.xls").Activate
Range("AF10").Select
Charts.Add
ActiveChart.ApplyCustomType ChartType:=xlUserDefined, TypeName:= _
"Compar_evol_vert"
ActiveChart.SetSourceData Source:=Sheets("U_01").Range("AG11:AG20"), PlotBy _
:=xlColumns
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(1).XValues = "=U_01!R11C33:R20C33"
ActiveChart.SeriesCollection(1).Values = "=U_01!R11C39:R20C39"
ActiveChart.SeriesCollection(1).Name = "=U_01!R10C39"
ActiveChart.SeriesCollection(2).XValues = "=U_01!R11C33:R20C33"
ActiveChart.SeriesCollection(2).Values = "=U_01!R11C41:R20C41"
ActiveChart.SeriesCollection(2).Name = "=U_01!R10C41"
ActiveChart.Location Where:=xlLocationAsObject, Name:="U_01"
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "Structure Clients"
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False
End With
NbGraph = Feuil1.ChartObjects.Count 'compte le nombre de graphiques dans la feuille
'le nouveau graphique correspond à l'index le plus élevé
Feuil1.ChartObjects(NbGraph).Name = "Le nom du Graphique"
With Feuil1.ChartObjects("Le nom du Graphique")
.Left = Range("M21").Left
.Top = Range("M21").Top
End With
En fait, j'ai réalisé la macro de redimensionnement grace a l'enregistreur et j'obtient cela :
ActiveChart.ChartArea.Select
ActiveSheet.Shapes("Graphique 93").ScaleWidth 1.07, msoFalse, _
msoScaleFromBottomRight
ActiveSheet.Shapes("Graphique 92").ScaleHeight 0.9, msoFalse, _
msoScaleFromTopLeft
ActiveSheet.Shapes("Graphique 92").ScaleWidth 1.3, msoFalse, _
msoScaleFromTopLeft
ActiveSheet.Shapes("Graphique 92").ScaleHeight 0.99, msoFalse, _
msoScaleFromTopLeft
ActiveSheet.Shapes("Graphique 92").ScaleHeight 0.82, msoFalse, _
msoScaleFromBottomRight
ActiveSheet.Shapes("Graphique 92").ScaleWidth 1#, msoFalse, _
msoScaleFromBottomRight
ActiveSheet.Shapes("Graphique 92").ScaleHeight 0.95, msoFalse, _
msoScaleFromBottomRight
ActiveSheet.Shapes("Graphique 92").ScaleHeight 0.98, msoFalse, _
msoScaleFromBottomRight
With Selection.Border
.ColorIndex = 50
.Weight = 1
.LineStyle = 3
End With
Selection.Interior.ColorIndex = xlAutomatic
Sheets("U_01").DrawingObjects("Graphique 92").RoundedCorners = True
Sheets("U_01").DrawingObjects("Graphique 92").Shadow = False
mon problème c'est qu'il utilise "shapes("Graphique 93")" alors que mon graphique s'appelle ChartObjects("Le nom du Graphique").
j'ai essayé de remplacer
ActiveChart.ChartArea.Select au debut par
Feuil1.ChartObjects("Le nom du Graphique").ChartArea.Select
mais ca ne fonctionne pas... je ne vois pas dutout comment faire!
si quelqu'un a une idée elle serait la bienvenue!
merci!
Dans ma une macro, je crée un graphique, et dans une autre, je le redimensionne, mais mon problème c'est que je n'arrive pas a selectionner mon graphique pour le redimensionner.
La macro de création :
ActiveWindow.Visible = False
Windows("Test_graph.xls").Activate
Range("AF10").Select
Charts.Add
ActiveChart.ApplyCustomType ChartType:=xlUserDefined, TypeName:= _
"Compar_evol_vert"
ActiveChart.SetSourceData Source:=Sheets("U_01").Range("AG11:AG20"), PlotBy _
:=xlColumns
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(1).XValues = "=U_01!R11C33:R20C33"
ActiveChart.SeriesCollection(1).Values = "=U_01!R11C39:R20C39"
ActiveChart.SeriesCollection(1).Name = "=U_01!R10C39"
ActiveChart.SeriesCollection(2).XValues = "=U_01!R11C33:R20C33"
ActiveChart.SeriesCollection(2).Values = "=U_01!R11C41:R20C41"
ActiveChart.SeriesCollection(2).Name = "=U_01!R10C41"
ActiveChart.Location Where:=xlLocationAsObject, Name:="U_01"
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "Structure Clients"
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False
End With
NbGraph = Feuil1.ChartObjects.Count 'compte le nombre de graphiques dans la feuille
'le nouveau graphique correspond à l'index le plus élevé
Feuil1.ChartObjects(NbGraph).Name = "Le nom du Graphique"
With Feuil1.ChartObjects("Le nom du Graphique")
.Left = Range("M21").Left
.Top = Range("M21").Top
End With
En fait, j'ai réalisé la macro de redimensionnement grace a l'enregistreur et j'obtient cela :
ActiveChart.ChartArea.Select
ActiveSheet.Shapes("Graphique 93").ScaleWidth 1.07, msoFalse, _
msoScaleFromBottomRight
ActiveSheet.Shapes("Graphique 92").ScaleHeight 0.9, msoFalse, _
msoScaleFromTopLeft
ActiveSheet.Shapes("Graphique 92").ScaleWidth 1.3, msoFalse, _
msoScaleFromTopLeft
ActiveSheet.Shapes("Graphique 92").ScaleHeight 0.99, msoFalse, _
msoScaleFromTopLeft
ActiveSheet.Shapes("Graphique 92").ScaleHeight 0.82, msoFalse, _
msoScaleFromBottomRight
ActiveSheet.Shapes("Graphique 92").ScaleWidth 1#, msoFalse, _
msoScaleFromBottomRight
ActiveSheet.Shapes("Graphique 92").ScaleHeight 0.95, msoFalse, _
msoScaleFromBottomRight
ActiveSheet.Shapes("Graphique 92").ScaleHeight 0.98, msoFalse, _
msoScaleFromBottomRight
With Selection.Border
.ColorIndex = 50
.Weight = 1
.LineStyle = 3
End With
Selection.Interior.ColorIndex = xlAutomatic
Sheets("U_01").DrawingObjects("Graphique 92").RoundedCorners = True
Sheets("U_01").DrawingObjects("Graphique 92").Shadow = False
mon problème c'est qu'il utilise "shapes("Graphique 93")" alors que mon graphique s'appelle ChartObjects("Le nom du Graphique").
j'ai essayé de remplacer
ActiveChart.ChartArea.Select au debut par
Feuil1.ChartObjects("Le nom du Graphique").ChartArea.Select
mais ca ne fonctionne pas... je ne vois pas dutout comment faire!
si quelqu'un a une idée elle serait la bienvenue!
merci!