object shape size

Corman

New Member
Joined
Mar 20, 2002
Messages
27
Hi.

Is it possible to program the width and height of an object added onto a chart?

To position a range I can use:
selection.shaperange.left = value
selection.shaperange.top = value

But, if I want to change the proportions of the actual shape (not the shape range), is it possible? selection.shaperange.width/height do not seem to work.

Thanks,
Corey
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
What I want is for the horizontal size of the object (basically a legend for the x-axis that is located at the top of the chart area) to be equal to the horizontal length of the chart/plot area. Is it possible to find the width of the plot area, then set the width of the object to that same value?

Thanks,
Corey
 
Upvote 0
Hi,

It is possible to change the shape and position of you object:

I guess position you have figured out, and the codes for width and height are:

Sheet1.ComboBox1.ShapeRange.Left = 50
Sheet1.ComboBox1.ShapeRange.Top = 100
Sheet1.ComboBox1.Width = 100
Sheet1.ComboBox1.Height = 20

The last two lines. Hope it helps.
 
Upvote 0
Thanks for the reply. That doesn't seem to work for me, though.

The object I'm trying to resize is located on a chart. I don't know if that makes a difference or not. This is the code I'm using:


Sub MoveObject()
ActiveSheet.ChartObjects("Chart 11").Activate
ActiveChart.ChartArea.Select
ActiveChart.Shapes("Group 23").Select
Selection.ShapeRange.LockAspectRatio = msoFalse
Selection.ShapeRange.Height = 45
Selection.ShapeRange.Width = 413
Selection.ShapeRange.Left = 65
Selection.ShapeRange.Top = 10
End Sub


The size of the object will not change, regardless of what I put as values for the height/width. I've tried with the aspect locked/unlock, and that doesn't do anything to help me either.

It seems to be resizing the range of the shape, but not the object itself (best way I can think to describe it is to think of a gif image: if you change the height/width attributes, the image itself doesn't change, just the size of the 'box' or 'container' the picture is located in - thus you have more room to put in extra info such as a second image).

Any more help/ideas?

Thanks,
Corey
 
Upvote 0
Tried to use this also, with no luck:

ActiveChart.Shapes("Group 23").Height = 45
ActiveChart.Shapes("Group 23").Width = 413


Can anyone help?
 
Upvote 0

Forum statistics

Threads
1,214,574
Messages
6,120,329
Members
448,956
Latest member
Adamsxl

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top