ChartingQuestion

  • Thread starter Thread starter Randal W. Hozeski
  • Start date Start date
R

Randal W. Hozeski

How do I resize the active Chart if the Chart name changes each time one is
generated.

' ActiveSheet.Shapes("Chart 88").ScaleWidth 1.46, msoFalse, _
' msoScaleFromBottomRight
' ActiveSheet.Shapes("Chart 88").ScaleHeight 1.22, msoFalse, _
' msoScaleFromBottomRight
' ActiveSheet.Shapes("Chart 88").ScaleWidth 1.29, msoFalse,
msoScaleFromTopLeft

Next time I generate a chart, it is not "Chart 88" anymore and returns an
error.
Thanks. -Randy-
 
I'm not certain of when you're wanting to change the dimensions, but...
You might be able to use ActiveChart instead of ActiveShet.Shapes("Chart
88")
 
No this did not work. It does not like the
.ScaleWidth or .ScaleHeight

When? After created, I adj charts options and
am trying to enlarge it. -Randy-
 
The suggestion may not have worked for a few reasons.

You can't change the size of a chart, but you can change the size of a
chart object, which is the parent of the chart. You can use something
like this:

With ActiveChart.Parent
.Width = 325 ' dimensions in points
.Height = 250
.Top = 150 ' position in points from top left of cell A1
.Left = 125
End Width

But the chart object cannot be scaled the way a shape can. If you need
to use ScaleWidth instead of Width, try this:

ActiveSheet.Shapes(ActiveChart.Parent.Name).ScaleWidth 1.5, _
msoFalse, msoScaleFromTopLeft

or

ActiveChart.Parent.Width = 1.5 * ActiveChart.Parent.Width

- Jon
 
THANKS! The first option worked.
As long as the chart is active.

It seems that once I de-activate the chart
and do something else then want to go back
to it. It puts that ("Chart 88") back in.

I was going to try and give it a name to use
so I could go back to it....

How can I return a once active chart that was
de-activated back to active? I want to remove
the chart so I can regenerate it. -Randy-
 
Randy -

I just answered your more recent post about naming a chart. Follow one
of those techniques, and name the chart something that you will look for
later for deletion ("Working Chart" or "Temp Chart", whatever). Then
just use a line like this before recreating the chart:

ActiveSheet.ChartObjects("Working Chart").Delete

An alternative is to keep the same chart, but redefine its source data
and change axis titles or whatever. This might be easier or more
reliable than rebuilding the chart every time.

- Jon
 
Back
Top