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

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

Code:
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.

Code:
Sub CountSelectedShapes()

Dim s As Shape
Dim n As Double

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

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

End If

End Sub

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