One of the things I noticed when reviewing Visio’s User Voice was the request for being able to have the shapes (they are actually masters) in the stencils be sorted. This is some code I have for keeping the masters in the document stencil sorted.
Here is the before and after.
Public Sub SortStencil() Dim i As Integer Dim j As Integer Dim pntr As Integer Dim lastmst As String Dim mstrcnt As Integer mastrcnt = ThisDocument.Masters.Count For i = 1 To mastrcnt lastmst = "" pntr = 0 For j = i To mastrcnt If ThisDocument.Masters(j).Type = 1 Then If ThisDocument.Masters(j).Name > lastmst Then lastmst = ThisDocument.Masters(j).Name pntr = j End If End If Next j If pntr > 0 Then ThisDocument.Masters(pntr).IndexInStencil = 1 Next i End Sub
I hope this helps.
John… Visio MVP in x-aisle