How can I get a count of the number of shapes in a Visio page?

A

Argently

I have a Visio drawing with at least a thousand shapes in it. Someone
created a background - grey with white stripes - with small shapes rather
than one box with a pinstripe fill. D'oh.

I need to count the number of shapes in this drawing. But I just can't seem
to do so. Your help will be deeply appreciated! Thanks,

Argently
 
A

Al Edlund

are we talking about all of the pages in the document, or just one page.
you might try putting this in as a macro and call it from the toolbar
al

Public Sub CountShapes()
Dim visDoc As Visio.Document
Dim visPage As Visio.Page
Set visDoc = Application.ActiveDocument
Dim intPage As Integer
Dim intCount As Integer
intCount = 0
Dim intTotal As Integer
intTotal = 0
For intPage = 1 To visDoc.Pages.Count
Set visPage = visDoc.Pages(intPage)
intCount = visPage.Shapes.Count
intTotal = intTotal + intCount
MsgBox "Page " & intPage & " has " & CStr(intCount) & " shapes"
Next intPage

MsgBox "Total Shapes = " & intTotal

End Sub
 
M

Mark Nelson [MS]

Note that this code counts top-level shapes but not sub-shapes of groups.
You may only be interested in top-level shapes, but if you are trying to
gauge bloat you would need to recurse into each group and count the
sub-shapes.

--
Mark Nelson
Office Graphics - Visio
Microsoft Corporation

This posting is provided "AS IS" with no warranties, and confers no rights.
 
M

Michel LAPLANE

You can also create a layer, select all your shape and put them on this
layer. Then use the layers command to view the layers dialog box and click
on the "#" column header it will gives you the number of shape including sub
shapes.
However be aware that the group are numbered as shape ; for example, if you
have one 2D shape it will show 1, if you group that shape it will show 2.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top