Hi guys,
I've used the information on this board quite often, first time to ask a question myself. I didn't seem to find anything simular on the board and hope I formulate this question clearly and in the correct form...
My problemconcerns the positioning of a shape in a chart. The chart itself is part of aworksheet. The chart is an XY scatter plot. The origin of the X and Y-axis isin the left top corner of the chart, the X-axis is from left to right, theY-axis is from top to bottom. I try to add a rectangle next to the chart, startingat the same height as my X-axis and the length should be the same as the lengthof the chart.
Toaccomplish this I tried first to obtain the position of the chart in theworksheet and afterwards the position of the origin of the X and Y-axis in thechart and also the width and height of the chart. Alas, I seem to be doingsomething wrong as I dont get the expected result and I cannot seem to figureout what values I obtain for the parameters above.
My code:
Dim ws AsWorksheet
Dim p AsPlotArea
Dim c AsChart
Dim H, W,L, T, hi, wi, Li, ti As Double
Set ws =ActiveSheet
Set c =ws.ChartObjects("Grafiek 1").Chart
Set p =c.PlotArea
H =p.height 'height of chart?
W =p.width 'width of charT?
L =p.left 'X-position of top left corner ofchart?
T =p.top 'Y-position of top left cornerof chart?
hi =p.InsideHeight 'height of Y-axis?
wi =p.InsideWidth height of X-axis?
Li =p.InsideLeft 'X-position of origin of Xand Y-axis?
ti =p.InsideTop 'Y-position of origin of Xand Y-axis?
Set shp =ws.Shapes.AddShape(msoShapeRectangle, L + Li, T + ti, 20, hi)
I hope someone can help me.
thank you all in advance,
HansV
I've used the information on this board quite often, first time to ask a question myself. I didn't seem to find anything simular on the board and hope I formulate this question clearly and in the correct form...
My problemconcerns the positioning of a shape in a chart. The chart itself is part of aworksheet. The chart is an XY scatter plot. The origin of the X and Y-axis isin the left top corner of the chart, the X-axis is from left to right, theY-axis is from top to bottom. I try to add a rectangle next to the chart, startingat the same height as my X-axis and the length should be the same as the lengthof the chart.
Toaccomplish this I tried first to obtain the position of the chart in theworksheet and afterwards the position of the origin of the X and Y-axis in thechart and also the width and height of the chart. Alas, I seem to be doingsomething wrong as I dont get the expected result and I cannot seem to figureout what values I obtain for the parameters above.
My code:
Dim ws AsWorksheet
Dim p AsPlotArea
Dim c AsChart
Dim H, W,L, T, hi, wi, Li, ti As Double
Set ws =ActiveSheet
Set c =ws.ChartObjects("Grafiek 1").Chart
Set p =c.PlotArea
H =p.height 'height of chart?
W =p.width 'width of charT?
L =p.left 'X-position of top left corner ofchart?
T =p.top 'Y-position of top left cornerof chart?
hi =p.InsideHeight 'height of Y-axis?
wi =p.InsideWidth height of X-axis?
Li =p.InsideLeft 'X-position of origin of Xand Y-axis?
ti =p.InsideTop 'Y-position of origin of Xand Y-axis?
Set shp =ws.Shapes.AddShape(msoShapeRectangle, L + Li, T + ti, 20, hi)
I hope someone can help me.
thank you all in advance,
HansV