specifying chart size

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
 
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
 
Back
Top