View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Peter T Peter T is offline
external usenet poster
 
Posts: 5,600
Default Names of Grouped Shapes

Maybe someone who has xl97 (or remembers xl97 better than I do) will
chime in.


Ding-dong

Even in XL97 I don't think you can directly name duplicates (vaguely recall
an msDrawings update for Office97, maybe that changed things). However, in
XL97, XL2k and I think(?) later versions duplicate shape names can be
created like this:

1. Rename some shapes from their original default names
2. Select these shapes, copy & paste
4. Group the pasted selection (without unselecting after pasting)

Ungroup and compare names.

Mogwai - I'm sure you're not going to resolve your problem unless all your
shapes have unique names. Application.caller returns the name of the
OnAction shape that called the macro. Confusion if duplicate names.

Try something like this to rename them

Sub ReNameGpItems()
Dim obGI As Object '
Dim grpObj As GroupObject

For Each grpObj In ActiveSheet.GroupObjects
i = i + 1
For Each obGI In grpObj.ShapeRange.GroupItems
s = "Gp" & Format(i, "00") & obGI.Name
obGI.Name = s
Next
Next
End Sub

Above assumes shapes are already grouped but only one level of grouping. For
multiple group layers would need a recursive type function.

Regards,
Peter T

Mogwai wrote:

Hi Dave,

Yes, I'm using xl97.

I thought there may be an index behind a shape/group that could be
returned, or referenced instead of the .name, but if you are at a loss
then I'm totally fugged! :-)

Thanks for having a look and for the aforementioned code.


--

Dave Peterson