ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Grouped shape name (https://www.excelbanter.com/excel-programming/385355-grouped-shape-name.html)

Janie

Grouped shape name
 
I know how to use ActiveSheet.Shapes(Application.Caller).Name to get the name
of the shape which is running a macro. BUT! If that shape is a GROUPED
shape, that line runs the name of the individual piece, not the name of the
group. What would I use to show the name of the Group? Or how about show
the name of the group that the particular shape is a member of???

Any thoughts?


Tom Ogilvy

Grouped shape name
 
Sub Shp_click()
MsgBox Application.Caller
MsgBox ActiveSheet.Shapes( _
Application.Caller).ParentGroup.Name
End Sub

--
Regards,
Tom Ogilvy


"Janie" wrote:

I know how to use ActiveSheet.Shapes(Application.Caller).Name to get the name
of the shape which is running a macro. BUT! If that shape is a GROUPED
shape, that line runs the name of the individual piece, not the name of the
group. What would I use to show the name of the Group? Or how about show
the name of the group that the particular shape is a member of???

Any thoughts?


joel

Grouped shape name
 
I would think it is .parent.name


I added a rectangle and an oval to my worksheet then grouped the items. the
I ran this test code

Sub getdim()

For Each shp In Sheets("sheet1").Shapes
Myname = shp.Name

Next shp

end sub


I only had one shape on my worksheet called group 6
In group 6 I had Item1 and Items.

Item1.name "rectangle 4"
Item2.name "oval 5"

I usually add a watch to my VBA window and then go exploring to find out the
proper way to identify items.

I would do someting like this
set Myshape = ActiveSheet.Shapes("shape Name")
then set a watch on Myshape a see if there is a parent and check the parent
properties.

"Janie" wrote:

I know how to use ActiveSheet.Shapes(Application.Caller).Name to get the name
of the shape which is running a macro. BUT! If that shape is a GROUPED
shape, that line runs the name of the individual piece, not the name of the
group. What would I use to show the name of the Group? Or how about show
the name of the group that the particular shape is a member of???

Any thoughts?


Janie

Grouped shape name
 
Thanks, Tom. That was it! I had tried Parent, but that gives you the name
of the worksheet.

Janie

"Joel" wrote:

I would think it is .parent.name


I added a rectangle and an oval to my worksheet then grouped the items. the
I ran this test code

Sub getdim()

For Each shp In Sheets("sheet1").Shapes
Myname = shp.Name

Next shp

end sub


I only had one shape on my worksheet called group 6
In group 6 I had Item1 and Items.

Item1.name "rectangle 4"
Item2.name "oval 5"

I usually add a watch to my VBA window and then go exploring to find out the
proper way to identify items.

I would do someting like this
set Myshape = ActiveSheet.Shapes("shape Name")
then set a watch on Myshape a see if there is a parent and check the parent
properties.

"Janie" wrote:

I know how to use ActiveSheet.Shapes(Application.Caller).Name to get the name
of the shape which is running a macro. BUT! If that shape is a GROUPED
shape, that line runs the name of the individual piece, not the name of the
group. What would I use to show the name of the Group? Or how about show
the name of the group that the particular shape is a member of???

Any thoughts?



All times are GMT +1. The time now is 10:04 AM.

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