counting items with visio / vba

E

eric

Hi !

I'm currently developing VBA from access to generate a Visio doc.

All is pretty well, but sometimes, I guess when I use grouped elements
(masters for example) there is a lot of crap
I need to keep an eye on each drop element (masters, lines ...)

If I drop a complex master made from grouped lines and then use
document_visio.pages(1).shapes.count

I'm going to have: 1

When I drop a line, or a master or anything else, and I want to modify it, I
need to have its number, in order to call it like that
Doc.Pages(p).Shapes.ItemFromID(21).CellSRC(....)

and this 21 is very different from the 1 I can have with the shapes.count
function.

I guess there is a different solution to resize master, color lines ...
but my application is pretty big and I don't want to rewrite all the code

Does anybony know the way to get the real number of items on a page ?
If you do, thank you, that'll be a great help :)

Eric
 
C

Chris Roth [ Visio MVP ]

I guess the "real number" of things on a page is debatable in a philosophic
sense. If I drop a computer monitor shape on the page, that is "one thing".
I don't care about the rectangles inside the shape that make the monitor
look realistic. But it looks like you are approaching the drawing from CAD
perspective. So here are a few notes:

Groups can contain sub-shapes. To get at sub-shapes, you can look at the
shp.Shapes collection for any shape variable, shp. shp.Type can help tell
you if a shape is a group, but it's often easier to just ask for
shp.Shapes.Count.

Shape geometry can also be combined. This is a way to put arcs and lines
together in a shape without grouping. It's a more "flat" structure. Instead
of separate sub-shapes, you'll have separate geometry sections in the
ShapeSheet of a single shape. Look at the shp.GeometryCount property of a
shape.

There are more tips and tricks here:

Visio development info:
-----------------------------------------
http://msdn.microsoft.com/office/understanding/visio/
http://www.mvps.org/visio/VBA.htm

--

Hope this helps,

Chris Roth
Visio MVP
 

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