Thread: Count of shapes
View Single Post
Old 11-05-2018, 18:37
knowbodynow knowbodynow is offline
Senior Member
Join Date: Mar 2006
Location: Hatsukaichi near Hiroshima
Posts: 434

Sorry I don't understand the question. If you have used ActiveDoucment,ClearSelection then the shape count should be 0.

Sub count()

MsgBox ActiveSelection.Shapes.count

End Sub
Note this treats grouped object as a single shape. The following makes a duplicate of the selection, ungroups it and counts all the shapes before deleting the duplicate.

Sub CountSelectedShapes()

Dim s As Shape
Dim n As Double

If ActiveSelection.Shapes.count > 0 Then
    Set s = ActiveSelection.Duplicate
    n = s.Shapes.count
    MsgBox "The number of shapes is: " & n, vbInformation, "Active Selection Count"

    MsgBox "Please select some shapes.", vbExclamation, "Oops!"

End If

End Sub

Last edited by knowbodynow; 11-05-2018 at 18:48.
Reply With Quote