ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   error in setting chart area width (https://www.excelbanter.com/excel-programming/402840-error-setting-chart-area-width.html)

tony

error in setting chart area width
 
sThis snipet of code fails in the with black while trying to set .width = 200

sub a()
Set co = ActiveSheet.ChartObjects.Add(cw * 3, rh * 0.5, cw * 8, rh * 20)
' Name it
co.Name = "ChartExample"

With co.Chart.ChartArea
.Width = 200
End With

end sub


JLGWhiz

error in setting chart area width
 
I couldn't get it to work either. It gives me an error for both width and
height as unable to set for ChartArea class. It did work for setting the
pattern for the chart area, so I'm thinking that this is a Microsoft SNAFU.

"TONY" wrote:

sThis snipet of code fails in the with black while trying to set .width = 200

sub a()
Set co = ActiveSheet.ChartObjects.Add(cw * 3, rh * 0.5, cw * 8, rh * 20)
' Name it
co.Name = "ChartExample"

With co.Chart.ChartArea
.Width = 200
End With

end sub


Peter T

error in setting chart area width
 
The chartarea's width & height properties are read only, determined by the
chartobject's size, just a couple of pixels or so inside allowing for the
border. So to change the chartarea's size re-size the chartobject. You can
re-size the PlotArea though the chart would need at least one series.

In passing, in a chart-sheet the chartarea's size is determined by the
sheet's PageSetup settings.

Regards,
Peter T

"TONY" wrote in message
...
sThis snipet of code fails in the with black while trying to set .width =

200

sub a()
Set co = ActiveSheet.ChartObjects.Add(cw * 3, rh * 0.5, cw * 8, rh * 20)
' Name it
co.Name = "ChartExample"

With co.Chart.ChartArea
.Width = 200
End With

end sub





All times are GMT +1. The time now is 03:03 AM.

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