ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   specifying chart size (https://www.excelbanter.com/excel-programming/285862-specifying-chart-size.html)

No Name

specifying chart size
 
How do you set the size of an embedded chart? I tried

sub foo()


Charts.Add

............

ActiveChart.ChartArea.Height = 200

...........

end sub

but .height is read-only. Also tried using .Shapes, but I
need the name of the shape (??) . Thanks

Lin Joyner

specifying chart size
 
Try using the ChartObject.Height property. I haven't tested it, but the help
files say...
This example sets the height of the embedded chart.

Worksheets("Sheet1").ChartObjects(1).Height = 288Hope that helps
Lin

wrote in message
...
How do you set the size of an embedded chart? I tried

sub foo()


Charts.Add

...........

ActiveChart.ChartArea.Height = 200

..........

end sub

but .height is read-only. Also tried using .Shapes, but I
need the name of the shape (??) . Thanks




PBezucha[_2_]

specifying chart size
 
Try the following elaborated procedure.
Merry Xmas.
PB

Sub ChartSize()
'Setting the sizes of the selected chart in mm
Dim ErrMsg As String, MB As Long
'PointSize is a scale coefficient – can be adjusted
Const PointSize = 2.83, TMB = "Chart size"
On Error GoTo NoSelection
Set S = Selection.Parent
'If something other than the chart is selected
If S.Type < -4169 Then ErrMsg = "No chart": GoTo ErrExit
'Default sizes can be adjusted
ChartHeight = InputBox("Height /mm", TMB, 85)
If ChartHeight = "" Then Exit Sub
ChartWidth = InputBox("Width /mm", TMB, 100)
If ChartWidth = "" Then Exit Sub
'If the input is wrong
ErrMsg = "No correct object"
On Error GoTo ErrExit
S.Parent.Height = ChartHeight * PointSize
S.Parent.Width = ChartWidth * PointSize
On Error GoTo 0
Exit Sub
NoSelection:
ErrMsg = "No object"
ErrExit:
MB = MsgBox(ErrMsg & " was selected", vbCritical, TMB)
On Error GoTo 0
End Sub

-----Original Message-----
Try using the ChartObject.Height property. I haven't

tested it, but the help
files say...
This example sets the height of the embedded chart.

Worksheets("Sheet1").ChartObjects(1).Height = 288Hope

that helps
Lin

wrote in message
...
How do you set the size of an embedded chart? I tried

sub foo()


Charts.Add

...........

ActiveChart.ChartArea.Height = 200

..........

end sub

but .height is read-only. Also tried using .Shapes, but

I
need the name of the shape (??) . Thanks



.


Jon Peltier[_4_]

specifying chart size
 
Alternatively, try this example on my web site, which lets you select a
range of data and a range of cells for the chart to cover:

http://www.geocities.com/jonpeltier/...tCreation.html

- Jon
-------
Jon Peltier, Microsoft Excel MVP
http://www.geocities.com/jonpeltier/Excel/index.html
_______

wrote:

How do you set the size of an embedded chart? I tried

sub foo()


Charts.Add

............

ActiveChart.ChartArea.Height = 200

...........

end sub

but .height is read-only. Also tried using .Shapes, but I
need the name of the shape (??) . Thanks




All times are GMT +1. The time now is 04:15 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com