View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson[_3_] Dave Peterson[_3_] is offline
external usenet poster
 
Posts: 2,824
Default Get the name of a group given the reference to a shape within thegroup

Maybe you can loop through the objects that are grouped and pick out what you
want:

Option Explicit
Sub testme02()

Dim wks As Worksheet
Dim sh1 As Shape
Dim sh2 As Shape
Dim iCtr As Long
Dim itemCount As Long

Set wks = ActiveSheet

For Each sh1 In wks.Shapes
itemCount = 0
On Error Resume Next
itemCount = sh1.GroupItems.Count
On Error GoTo 0
If itemCount 0 Then
For iCtr = 1 To itemCount
Set sh2 = sh1.GroupItems(iCtr)
If sh1.GroupItems(iCtr).Connector Then
Debug.Print sh2.ConnectorFormat.BeginConnectedShape.Name
End If
Next iCtr
End If
Next

End Sub


Andrew wrote:

I have a series of drawing objects connected by connector lines. I am
using the following to retrieve the name of the object connected by
the line:

dim sh as shape
For Each sh In ActiveSheet.Shapes
debug.print sh.ConnectorFormat.BeginConnectedShape.Name
Next

However, for grouped objects this returns the name of the sub item
which the connector is attached to rather than the group name, eg.
"Line32" is returned rather than "Group15", where Line32 is contained
within Group15.

Is there any way to determine the name of the group that a particular
object making up that group is in?

Thanks a lot,
Andrew


--

Dave Peterson