Reputation: 21
I created two oval shape objects which are named by default as "Oval 1" and "Oval 2". I grouped both of them and named it "MergedOvals". I assigned a macro to the newly formed group shape.
The macro has code that gives the name of the shape object when I click it:
Sub ClickedShape()
MsgBox ActiveSheet.Shapes(Application.Caller).Name & " Clicked"
End Sub
The problem is, when I click the grouped shapes, I am expecting the MsgBox to show "MergedOvals Clicked", but instead, the original "Oval 1" or "Oval 2" names are shown depending on the proximity of the cursor to the ovals.
Is there a way that it should show the grouped name?
Upvotes: 2
Views: 3214
Reputation: 149335
As mentioned Here, work with objects so that you can access the intellisense. That way you can discover what all Object Properties
you have at your disposal.
Is this what you are trying?
Sub ClickedShape()
Dim shp As Shape
Set shp = ActiveSheet.Shapes(Application.Caller)
MsgBox shp.ParentGroup.Name & " Clicked"
End Sub
Upvotes: 0