count shapes

G

Gijs

I have a problem:

I need to count the shapes on one page with a VBA code. But I need to count
one kind of shape that is dropped multiple times on the page. There are
other shapes on the page, but I don't want to count them.
A second question is: how can I keep the shapes apart, has every shape,
thats dropped on the page multiple times, an exclusive ID so I can keep them
apart?
 
D

David Parker [Visio MVP]

Every shape has a unique ID, name and, optionally, a GUID.
You can manually/programatically change the name (limit of 31 chracters - no
special characters)

To count just your own, you need to be able to recognise something about it,
eg its master , or a particular cell value, such as a custom property or
user cell.
 
G

Gerald K

Following on David's advice, a couple of examples that might help:

Dim srcShapes As Visio.Shapes
Dim srcShape As Visio.Shape

For Each srcShape In srcShapes
If Not (srcShape.Master Is Nothing) Then
'If a shape master exists
Set objMstr = srcShape.Master
' Get Master property of shape
If objMstr.Name Like ("mstr name") Then
'do stuff
end if
end if
next

or if you want to search a field such as the object's text field:

If srcShape.Text Like ("sometext") Then
'do something
End if
 

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