Whose your father?

Visio does provide an option for printing shapesheets but it is wordy. In the past I have used Excel to sort and manipulate the information, but this is time consuming and really does not give me everything I want. One thing that was not easy to do was to find out whether a shapesheet was part of a group and if so, which group it belonged to. Being Visio, this is not a big problem. The object model is exposed and it is possible to write your own version of the shapesheet print Add-in with a routine to show the lineage of a shapesheet. 

Given a Visio shape, this function will return a string that lists its’ ancestors. 

Private Function Heritage(shpObj As Visio.Shape) As String

Dim Finished     As Boolean
Dim tmpName   As String
Dim tmpString   As String

tmpName = shpObj.Name
tmpString = tmpName

Finished = False
Do While Not Finished

    If ActivePage.Shapes(tmpName).Parent.Type = visTypeGroup Then
        tmpName = ActivePage.Shapes(tmpName).Parent.Name
        tmpString = tmpName + ” ” + tmpString
        Finished = True
    End If

Heritage = tmpString

End Function

This sample code will eventually make it’s way over to http://visio.mvps.org/VBA.htm

Leave a Reply

Your email address will not be published. Required fields are marked *