The macro checks the color of both the connectors and the shapes. It does this to avoid entering a shape more than once into the shape array, and to avoid multiple counting of any connector. As such, closed loops will create an error, some or every (

) time.
The way the macro works is
1. Start with selected shape, look at every connector
2. Only examine connectors that meet the direction requirement, i.e., "m".
3. Check the connector to see if it's been used before, if so, skip.
4. Check the opposite end of the connector.
A. If shape is the originating shape, ignore. The connects connection always includes the originating shape.
B. Check to see if the shape has already been used, i.e., its color, if so, ignore
C. Everything OK, increment "j", the shape array index,redim the array, add new shape.
D. Increment the connector count by one
Macro loops thru every connector, counts each new connector, adds shape to shape array, then loops thru the shape array until all shapes in the array, "k", have been checked. It terminates when "k" exceeds "j". A closed loop throws off the, "j", "k" relationship.
It's a simple macro, not anticipating existence of loops. Some special conditional requirements are needed...
1. Allow original shape, possibly
2. Allow double counting of shape, but not re-add to the array, otherwise, end up with endless, repeating loop.
I would recommend making a simple, 3 shape loop, step thru program, see where/why it breaks, then establish some conditional test to allow that scenario.
Since I'm not in front of my computer, the order of the steps may not be quite right....disclaimer!!!