Determining the group a picture or textbox is a member of

  • Thread starter Thread starter David Cuthill
  • Start date Start date
D

David Cuthill

If I select an item (picture or textbox) of a group how do
I determine what the group or group name the item is a
member of?

David
 
If the controls are grouped using Frame controls, you can use the Parent
property of the control to return the Frame that the control belongs to. Or,
depending on how you have formed the groups, you can use the GroupName
property of the control.
 
I'm sorry - I am refering to a picture or a label that is
inserted on a worksheet not a user form. The picture and
label form a grouped image and I want to determine the
group name if one of the grouped items is selected.


David
 
Do you mean labels from the Forms toolbox which have been subsequently
grouped? These labels are Shape objects and have a GroupItms which
returns their respective GroupShapes collection, but this collection
object doesn't have a Name property. How did you set the group's name
originally?

--
 
Sorry, not sure how to do that. Is this a real group that Excel recognizes,
or just what you consider to be a group? What were the mechanics of the
grouping process?
 
I create the group using code.

I insert a picture into the worksheet
(activesheet.picture.insert ...) and then create a textbox
(activesheet.shapes.addlabel ...) in close proximity to
the inserted picture. I then select the two items and
group them by using ...

ActiveSheet.Shapes.Range(Array(PictName, LabelName)).Select
Selection.ShapeRange.Group.Select

I then name the group using a preselected naming
convention.

What I want to be able to do is when either of the grouped
items is selected (which results in the name of the item
being displayed in the name box on the left hand side of
the formula bar) is determine, using code, which group the
selected item belongs to.

I have tried using things like Parent and GroupName but I
can't seem to get it work as appears that I am not
applying it to the correct object.


David
 
I believe I have figured it out ... after much searching.

ActiveSheet.Shapes(PictName).ParentGroup.Name

gives me the name of the group the shape belongs to.

Thanks
 
Glad you solved it!

--

Vasant

David Cuthill said:
I believe I have figured it out ... after much searching.

ActiveSheet.Shapes(PictName).ParentGroup.Name

gives me the name of the group the shape belongs to.

Thanks
 
Back
Top