trying to set chart width

B

bbxrider

my chart width can change due to setting axes, etc and i want to keep it a
certain size
have tried code like below, when the 'width' number i thought was points 72
per inch to keep chart at 6"
but not working, can this be done or is it a 'relative' size

ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.ChartArea.Select
ActiveSheet.Shapes("Chart 1").Width 452, msoFalse,
msoScaleFromTopLeft
 
J

Jon Peltier

I prefer to work with the ChartObject instead of the Shape:

ActiveSheet.ChartObjects("Chart 1").Width = 452

which seems to be in points. You can also set the width of a Shape with
the same syntax:

ActiveSheet.Shapes("Chart 1").Width = 452

The line of code you posted is almost the ScaleWidth method:

ActiveSheet.Shapes("Chart 1").Width 1.5, msoFalse, <corner>

The 1.5 in this line means stretch to 150% of its initial size. False
means relative to its current size; some objects allow you to use True,
relative to its original size. <corner> is the corner that stays put
when you stretch it. If you're going to an absolute size, you don't want
ScaleWidth.

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

bbxrider

thanks very much, i had macroed a size change and got fooled by the scale
width syntax
when trying to use it with 'point' width
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top