Create shape, name shape, add text to shape

  • Thread starter Thread starter Rick S.
  • Start date Start date
R

Rick S.

Hi, I decided to burst as many brain cells as I can working with shapes.
Its working. ;)

I am trying to add "Oval" shapes (msoShapeOval) tn image on a worksheet, the
problem I am having difficulties with is naming the shape or renaming the
shape as it is created.
I want to start with "Oval 1" for the First shape and continu counting, Oval
2, Oval 3, etc. What I get is what seems to be a random starting shape name
such as "Oval 6" when there are no shapes other than a picture shape on the
sheet or in the entire workbook.
Lets say It started with "Oval 6", I rename to "Oval 1" the next shape name
is going to be "Oval 7" by default; I can rename to "Oval 2" and so on until
I reach "Oval 12" and try to rename to "Oval 6". Instead of renaming it jumps
to the original "Oval 6" shape which was renamed to "Oval 1"?

1. Can I purge shapes from a worksheet or workbook?
2. How do I get the count to start where I want it to start at with out
duplicating the name?
 
Set Disc = .AddShape(msoShapeOval, LimitLeft, TopShape, HeightShape,
HeightShape)
With Disc
.Fill.ForeColor.RGB = ColorBackground
.Line.Visible = msoFalse
.ZOrder msoSendToBack
.Name = "Oval 12"
End With

Note that if another shape named "Oval 12" exists you might have to code to
find it and rename it before creating this shape, but since you said that
there were no other shapes, this should work for you.
 
Back
Top