Getting shapes and connections off visio document with

Are there "Getters" in the Visio 12.0 Type library that would allow me to programmatically get shape s and connections from a document?  I know I can write put shapes on the document using .  But I would like to reverse this process in a class library and return the information.
Who is Participating?
Scott HelmersVisio Consultant, Trainer, Author, and DeveloperCommented:
Getting information about the shapes in a drawing can be as easy as the code below.

The syntax is a bit more detailed if you want to access user data fields or shape data fields for each shape. If that's part of what you want, let me know.

Getting information about connections is a bit more obscure and requires more work, because prior to the upcoming Visio 2010, there is no notion of "connectedness" in a Visio drawing. If you want that information, you have to get it yourself. For a fairly complete description of why and how, including sample code, refer to my answer to Q_24608625.


Sub GetShapeInfo()

    Dim pg As Visio.Page
    Dim shp As Visio.Shape
    For Each pg In ActiveDocument.Pages
        For Each shp In pg.Shapes
            ' do something here with info about shape, e.g.
            Debug.Print shp.Name
End Sub

Open in new window

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.