plot area inconsistent sizes with VBA

  • Thread starter Thread starter Robert H
  • Start date Start date
R

Robert H

I run a series of charts on a single sheet that look at different but
similar types of data. the x-axis values are always the same. The y-
axis is the same count but different ranges of values. The charts are
set to be the same size and the plots are set to be the same size. On
some of the resulting charts the plot height is slightly smaller and
the plot width is about half even though the the plot areas are full
size.

here is the segment of code

With .Parent
.Top = chtLoc1.Offset(26, 0).Top
.Left = chtLoc1.Left
.Height = 252
.Width = 432
.Name = chtNm
End With


With ActiveChart.PlotArea
.Top = 20
.Height = 221
.Left = 0
.Width = 340
End With

the inconstancies occur at .plotarea.height and .width

I thing there must be another setting that is unique to the two charts
that this occurs on. the same code is cycled through to create each
chart.

Thanks
Robert
 
I have been trying to solve the same problem. I want to create charts all the same width and height (particularly width) to align them neatly, except depending on the y-axis value (no. of digits) the chart changes width...!

So despite defining the widths for Shape, ChartObject, ChartArea, and PlotArea as the same for two charts they can actually have different widths visually. It's infuriating and there must be some hidden variable somewhere. Any ideas...?

'Setting widths
sName = ActiveChart.Parent.Name
ActiveSheet.Shapes(sName).Width = nWidth

With ActiveChart
.Parent.Width = nWidth
.ChartArea.Width = nWidth
.PlotArea.Width = nWidth
End With



Robert H wrote:

plot area inconsistent sizes with VBA
16-Dec-08

I run a series of charts on a single sheet that look at different bu
similar types of data. the x-axis values are always the same. The y
axis is the same count but different ranges of values. The charts ar
set to be the same size and the plots are set to be the same size. O
some of the resulting charts the plot height is slightly smaller an
the plot width is about half even though the the plot areas are ful
size

here is the segment of cod

With .Paren
.Top = chtLoc1.Offset(26, 0).To
.Left = chtLoc1.Lef
.Height = 25
.Width = 43
.Name = chtN
End Wit

With ActiveChart.PlotAre
.Top = 2
.Height = 22
.Left =
.Width = 34
End Wit

the inconstancies occur at .plotarea.height and .widt

I thing there must be another setting that is unique to the two chart
that this occurs on. the same code is cycled through to create eac
chart

Thank
Robert

Previous Posts In This Thread:

plot area inconsistent sizes with VBA
I run a series of charts on a single sheet that look at different bu
similar types of data. the x-axis values are always the same. The y
axis is the same count but different ranges of values. The charts ar
set to be the same size and the plots are set to be the same size. O
some of the resulting charts the plot height is slightly smaller an
the plot width is about half even though the the plot areas are ful
size

here is the segment of cod

With .Paren
.Top = chtLoc1.Offset(26, 0).To
.Left = chtLoc1.Lef
.Height = 25
.Width = 43
.Name = chtN
End Wit

With ActiveChart.PlotAre
.Top = 2
.Height = 22
.Left =
.Width = 34
End Wit

the inconstancies occur at .plotarea.height and .widt

I thing there must be another setting that is unique to the two chart
that this occurs on. the same code is cycled through to create eac
chart

Thank
Robert


Submitted via EggHeadCafe - Software Developer Portal of Choice
Win a Free License of SandRibbon for Silverlight
http://www.eggheadcafe.com/tutorial...ee-license-of-sandribbon-for-silverlight.aspx
 
Robert -

The PlotArea has read-only properties .InsideLeft, .InsideTop,
..InsideWidth, and .InsideHeight, which define the dimensions of the
rectangle defined by the axes. You cannot change them directly, but you
can adjust the read/write properties .Left, .Top, .Width, and .Height in
order to fix the inside dimensions. When the configuration of axis
labels changes, you will likely need to repeat the resizing exercise.

Long ago I posted a routine within the following zip file which carries
out a resizing of chart plot area dimensions to unify the dimensions of
their plot area inside dimensions.

Align Chart Dimensions
http://peltiertech.com/Excel/Zips/AlignChartDimensions.zip

- Jon
 
Back
Top