definir la position (x,y) d1 graph sur une feuille excel

romainchu78

XLDnaute Occasionnel
bonjour a tous,
jai mis au point une macro qui permet de creer automatiquement un camembert et le copie sur une feuille excel. macro realiser a l'aide de l'enregistreur de macro.
le probleme c'est que suivant les largeurs des colonnes de donnees, il me place le cadre du camembert a plusieurs endroits different. alors que je voudrais que ce camembert soit genere a un endroit precis: le coin en haut a gauche du graph soit place sur la case H12 a chaque fois.

Quelqu'un a t'il une idee ?

voici la portion de mon code qui concerne la generation du camembert:




Charts.Add
ActiveChart.ChartType = xlPie
ActiveChart.SetSourceData Source:=Sheets(NomFichierCourt).Range("H5:I6,H8:I10"), PlotBy:=xlColumns
ActiveChart.Location Where:=xlLocationAsObject, Name:=NomFichierCourt
ActiveChart.SeriesCollection(1).Points(1).Select
With Selection.Interior
.ColorIndex = 15
.Pattern = xlSolid
End With

ActiveChart.SeriesCollection(1).Points(2).Select
With Selection.Interior
.ColorIndex = 33
.Pattern = xlSolid
End With

ActiveChart.SeriesCollection(1).Points(3).Select
With Selection.Interior
.ColorIndex = 41
.Pattern = xlSolid
End With

ActiveChart.SeriesCollection(1).Points(4).Select
With Selection.Interior
.ColorIndex = 5
.Pattern = xlSolid
End With

ActiveChart.SeriesCollection(1).Points(5).Select
With Selection.Interior
.ColorIndex = 55
.Pattern = xlSolid
End With

ActiveChart.SeriesCollection(1).ApplyDataLabels AutoText:=True, LegendKey:= _
False, HasLeaderLines:=True, ShowSeriesName:=False, ShowCategoryName:= _
True, ShowValue:=False, ShowPercentage:=True, ShowBubbleSize:=False
ActiveChart.PlotArea.Select

With Selection.Border
.ColorIndex = 16
.Weight = xlThin
.LineStyle = xlContinuous
End With
With Selection.Interior
.ColorIndex = 2
.PatternColorIndex = 1
.Pattern = xlSolid
End With
Range("A2").Select

ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.ChartArea.Select
ActiveSheet.Shapes("Chart 1").IncrementLeft 264.75
ActiveSheet.Shapes("Chart 1").IncrementTop 24.75
ActiveChart.Legend.Select
Selection.Delete
ActiveSheet.Shapes("Chart 1").ScaleWidth 0.9, msoFalse, msoScaleFromTopLeft
ActiveSheet.Shapes("Chart 1").ScaleWidth 0.87, msoFalse, msoScaleFromTopLeft
ActiveSheet.Shapes("Chart 1").IncrementTop 15#
ActiveWindow.Visible = False
Windows(nomfichier2).Activate
Range("J8:M8").Select
Range("M8").Activate
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.Merge
With Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = True
End With
Range("A2").Select
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.PlotArea.Select
Selection.ClearFormats


Je peux aussi ajouter des lignes de codes (c'est la meilleure solution pour ne pas interferer avec mon code actuel...

merci par avance
 

Statistiques des forums

Discussions
312 323
Messages
2 087 297
Membres
103 511
dernier inscrit
mickael.das