PDA

View Full Version : Align shapes within cells and fix their position



Digita
02-24-2009, 05:19 PM
Hi All,

Thanks for reading this post. I have a long list of data with rows of variable heights. I have many shape objects imbedded in form of pictures in a particular column for each row in the list. The code below resizes all the shapes and moves them in a particular manner.

Dim sShapes As Shape
'Loop through all shapes on Worksheet
For Each sShapes In ActiveSheet.Shapes

If Left(sShapes.Name, 7) = "Picture" Then
With sShapes
.ScaleWidth 0.5, msoFalse, msoScaleFromTopLeft
.ScaleHeight 0.4, msoFalse, msoScaleFromTopLeft
.IncrementLeft 0.75
.IncrementTop 27.75

End With
End If
Next sShapes

The problem I have after running the code is that the shapes have not been correctly aligned to the rows. Some are slightly below or above their original rows. :banghead:

I want to fix the position of the shapes so that they all align within the row and at the bottom left corner of the cells they are in. There is no such thing as "IncrementBottom" for the shapes object as the opposite to "IncrementTop", is there? Any workaround?

Enclosed is a small sample file for ease of reference. Hope you can help. Thanks in advance.

Regards


kp

Dave
02-25-2009, 12:40 AM
Well I tried it out and my "pictures" didn't adjust and I've had to give it the 3 finger salute several times. I'd like to learn abit more about shapes (aside: and their ability to "fill" GPS coordinates). For my trial of the code and your wb, I just added a couple of .gifs to the shape controls (1 large, 1 small to be more precise). Nothing happened to the size of the pics and then XL does something apparently again and again and again. Just looking for the 3 finger solution I guess. Maybe abit more info about the pictures, your intended final result and what the general purpose of the endeavour is might help get me up to speed. Shapes seem like an interesting learn. I'm sure someone will know how to assist you. Dave