Select the largest shape in page?

Hi. Does anybody know how to select the largest shape in page?

The problem is the following: I have many shapes within a large rectangle and also some shapes outside the same rectangle.

I want the macro to identify the largest shape in page (the rectangle in this case) and, based on its coordinates, to select all the shapes within the rectangle and group them alltogheter.

Thank you very much!

  • Instead of looping through each shape, you could use a little CQL to sort the shapes by the area. Then select the first shape which will be the largest. Here is an example:

    Sub SelectByLargestArea()
        Dim sr As ShapeRange
        Dim sLargest As Shape
        Set sr = ActivePage.Shapes.All
        sr.Sort " >"
        Set sLargest = sr.FirstShape
    End Sub

    Happy Coding,


Reply Children