Macro to Query ShapeRrange for intersecting lines?

Anyone suggest a code to tell me whether any of the objects selected have intersecting lines and if so pop up a message that says something to the effect "CAUTION: Intersecting lines"?

Parents
  • Myron, 

    This is a very simple approach to your question. It is just to give you something to build from. There are better ways to optimize the looping but I wanted to keep it simple. Also, if you have a shape that does not have a displaycurve such as text then this is going to error out.

    Sub DetectIntersects()
        Dim sr As ShapeRange
        Dim s1 As Shape, s2 As Shape
        Dim bFound As Boolean
        
        bFound = False
        Set sr = ActiveSelectionRange
        
        For Each s1 In sr.Shapes
            If bFound Then Exit For
            For Each s2 In sr.Shapes
                If Not s1 Is s2 Then
                    If s1.DisplayCurve.IntersectsWith(s2.DisplayCurve) Then
                        bFound = True
                        Exit For
                    End If
                End If
            Next s2
        Next s1
        
        If bFound Then MsgBox "Myron, Something Intersects!!!"
        If Not bFound Then MsgBox "Myron, Nothing Interects."
    End Sub
    

    Hope that gets you started, 

    -Shelby

Reply Children