Thread: Chart Size
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Jon Peltier[_7_] Jon Peltier[_7_] is offline
external usenet poster
 
Posts: 115
Default Chart Size

And when you make a chart, don't use Charts.Add. This first adds a chart
sheet, then transfers the chart to a sheet. Use the
Sheet.ChartObjects.Add directly. This allows you (forces you actually)
to include the position and size of the chart.

This is how it looks:

Sub AddChartObject()
With ActiveSheet.ChartObjects.Add _
(Left:=100, Width:=375, Top:=75, Height:=225)
.Chart.ChartType = xlXYScatterLines
.Chart.SetSourceData Source:=Sheets("Sheet1").Range("A3:G14")
End With
End Sub

For more hints on charting with VBA, check out this web page:

http://peltiertech.com/Excel/ChartsH...kChartVBA.html

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services
Tutorials and Custom Solutions
http://PeltierTech.com/
_______

Andy Pope wrote:

Hi Aja,

This routine will resize all the chartobjects on the activesheet.

Sub ResizeChartObjects()
Dim sngWidth As Single
Dim sngHeight As Single
Dim objCht As ChartObject

sngWidth = 100
sngHeight = 75
For Each objCht In ActiveSheet.ChartObjects
objCht.Width = sngWidth
objCht.Height = sngHeight
Next
End Sub

Is this what you meant?

Cheers
Andy

Aja wrote:

How can I code charts to be drawn at a predefined size so that I don't
have to resize the chart wizard output?
Aja