#1   Report Post  
Posted to microsoft.public.excel.programming
Aja Aja is offline
external usenet poster
 
Posts: 4
Default Chart Size

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,489
Default Chart Size

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


--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info
  #3   Report Post  
Posted to microsoft.public.excel.programming
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




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 50
Default Chart Size

With ActiveSheet.ChartObjects.Add _
(Left:=100, Width:=375, Top:=75, Height:=225)


Just a quick word of warning about using the above method.
If the worksheet's zoom setting is not at 100%, then the position
and size of the resulting chartobject may not be exactly what you
specified. Fortunately, setting the chartobject's Top, Left, Width
& Height properties explicitly works properly at all zoom settings.

Regards,
Vic Eldridge


"Jon Peltier" wrote in message
...
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






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
HOW TO FIX SIZE OF CHART BOX Khoshravan Charts and Charting in Excel 0 September 4th 07 11:36 AM
Size of Chart Paula Excel Discussion (Misc queries) 1 June 25th 07 05:04 PM
Chart size [email protected] Charts and Charting in Excel 1 May 17th 07 05:15 PM
Chart size JKC Charts and Charting in Excel 1 February 14th 06 04:30 PM
Chart Size Eric Van Buren Excel Programming 4 April 13th 04 09:26 PM


All times are GMT +1. The time now is 09:17 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"