Shapes collection

C

Chris

I'm using the Visio COM interface to process groups of shapes in a Visio
file. I need to be able to process the shapes in a particular order. I had
assumed that the ordering in the Drawing Explorer would be the same as the
ordering of elements in the Shapes collection but this isn't always the
case. In one instance, the shape (a group) I added first to the group
appears as the first item in Drawing Explorer but as the last item in the
Shapes collection. Apart from this the ordering of the other items is the
same.

Can someone tell me how the Shapes collection is ordered?
 
J

JuneTheSecond

The Index property shows the order of the shapes inthe Shapes collection,
The order is same as the z-order of the shapes on a page.
Z-order can easily be changed by user's operation, so the the order is not
stable.
ID property does not change, if the order changed.
I wonder you might assume that ID = Index, but it is not true.
 
C

Chris

Thanks. My initial assumption was that Shapes was ordered in chronological
order of being dropped on the page.

How do you change the order of the Shapes collection manually in Visio? I
have one shape that I want to set as the first item. I've tried 'Send to
Front / Back' but it has made no difference.
 
J

JuneTheSecond

case1 : Click a shape at the front among any other shapes, menu
[Shape]/[Order]/[Send to the deepest back], then the shape at the bottom
would become the first in the Shape collection. (I hope the name of the menus
might be corrected, because my language is not English.)
case2 : On the new blank drawing page, make a new group that include 2
shapes, in this step the order of the group is 3 in the Shapes collection,
create a new stencil, drag and drop the new group, it makes a master on the
stencil, again drag and drop the master onto the drawing page, in this step
the order of the group is 1 in the Shapes collection.

You might see and compare the order and Index, ID and Name with a macro
like,,,
Sub test()
Dim shp As Visio.Shape
For Each shp In ActivePage.Shapes
Debug.Print shp.Index, shp.ID, shp.NameID, shp.NameU, shp.Name
Next
End Sub
 
J

JuneTheSecond

Correction in case 2, sorry. It is not order but ID that changes. I am
confusing Index and ID, too.
 

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