Select shape with mouse

How i can select a shape with mouse?

  • You would use the GetUserClick and then SelectShapesAtPoint. Here is an example that when you click on a shape with a Uniform fill it will select all other shapes with that same fill. 

    To get out of the loop you need to press ESC. 

    Sub quickColorSelect()
        Dim x As Double, y As Double
        Dim s As Shape, s1 As Shape
        Dim sr As ShapeRange, sr2 As ShapeRange
        Dim Shift As Long, bClick As Boolean
        Dim c As New Color, c2 As New Color
    
        EventsEnabled = False
        
        Set sr = ActivePage.Shapes.FindShapes(Query:="@fill.type = 'uniform'")
        ActiveDocument.ClearSelection
        bClick = False
        While Not bClick
        On Error Resume Next
            bClick = ActiveDocument.GetUserClick(x, y, Shift, 10, False, cdrCursorPickNone)
            If Not bClick Then
                Set s = ActivePage.SelectShapesAtPoint(x, y, False)
                Set s = s.Shapes.Last
                c2.CopyAssign s.Fill.UniformColor
                Set sr2 = New ShapeRange
                For Each s1 In sr.Shapes
                    c.CopyAssign s1.Fill.UniformColor
                    If c.IsSame(c2) Then
                        sr2.Add s1
                    End If
                Next s1
                sr2.CreateSelection
                ActiveWindow.Refresh
            End If
        Wend
        
        EventsEnabled = True
    End Sub
    

    -Shelby