ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   refer to an object in a group (https://www.excelbanter.com/excel-programming/403179-refer-object-group.html)

Linda Edlund

refer to an object in a group
 
Is that possible to refer to an object in a group

ActiveSheet.Shapes("group_3"...?..."rectangle_4"). Select
or
ActiveSheet.Shapes("group_7"...?..."textbox_3").Te xt= "abc"


thanks

Andy Pope

refer to an object in a group
 
Hi,

You can access a shape within a group but not by name.
You have to use a numeric index.

The following should help. Add 3 rectangles to the active sheet and then
group them.

'---------------------------
Sub X()
Dim shpGroup As Shape
Dim shpTemp As Shape
'
Set shpGroup = ActiveSheet.Shapes(1)
If shpGroup.Type = msoGroup Then
For Each shpTemp In shpGroup.GroupItems
Debug.Print "Grouped shape ", shpTemp.Name
Next
With shpGroup.GroupItems(1)
.Fill.ForeColor.RGB = RGB(0, 255, 0)
End With
Else
' normal ungrouped shape
Debug.Print "Shape ", shpGroup.Name
End If
End Sub
'---------------------------

Cheers
Andy

Linda Edlund wrote:
Is that possible to refer to an object in a group

ActiveSheet.Shapes("group_3"...?..."rectangle_4"). Select
or
ActiveSheet.Shapes("group_7"...?..."textbox_3").Te xt= "abc"


thanks


Linda Edlund

refer to an object in a group
 
Thank you for the answer Andy


All times are GMT +1. The time now is 11:10 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com