The Shape.SpatialRelation property will tell you whether two shapes are touching. The Shape.Index property will tell you what is in front or behind in z-order.
Here is a simple example:
Public Sub DoShapesIntersect(ByRef shape1 As Visio.Shape, ByRef shape2 As Visio.Shape) '// do they touch? If (shape1.SpatialRelation(shape2, 0, 0) <> 0) Then '// they touch, which one is in front? If (shape1.Index > shape2.Index) Then Debug.Print shape1.Name + " is in front of " + shape2.Name Else Debug.Print shape1.Name + " is behind " + shape2.Name End If Else Debug.Print "shape1 and shape2 do not touch" End If End Sub
More details here:
Shape.SpatialRelation Property on MSDN
source share