View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Andrew[_16_] Andrew[_16_] is offline
external usenet poster
 
Posts: 66
Default Get the name of a group given the reference to a shape within the group

Thanks Dave & Jim,

The other idea that I had is to create an initialise sub which looks
for grouped items and sets the sub-shapes to the same name as the
group (but with a suffix appended). Now when I find the sub-shape I
can determine the name of its parent from its own name.

I like your approach too though Dave because - basically I can create
my own 'GroupParent' property this way. This appeals because
eventually once we upgrade to xl2002+ then I can easily update my
code.

Yet to decide which way to go. The other thing I've done in the
meantime is to minimise the number of grouped shapes.

Thanks again - your ideas really appreciated.

Andrew


Dave Peterson wrote in message ...
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