Programatically reading visio diagram data

Joined
Mar 13, 2012
Messages
2
Reaction score
0
Hello all,
I have some visio statecharts, and to get the complete state and transition information, I go to Tools>Visio Addons>Export to database option and select excel file to store all the visio diagram data.

However, I am trying to automate this, and need to know how to programatically read the visio drawing data so that I can store this data inside an array or something.

I refered the MSDN documentation, but wasn't able to find exact methods which would let me access the drawing information.
Could anyone help me on this please?
Any reference C# code would also work great as a reference.

Thanks!
 
Joined
Feb 7, 2012
Messages
6
Reaction score
0
You can't read the data directly from the Visio vsd file, but you do have access to everything in the drawing via the Visio object model.

You'll need the Visio 2010 SDK to get the information you need. It also contains lots of code samples. You can view it online or download it; just search for Visio 2010 SDK.

There's a bit of a learning curve, as there is with any object model, but everything is there...
 
Joined
Mar 13, 2012
Messages
2
Reaction score
0
I have programmatically open a .vsd file and taken its reference. I am looking for the appropriate methods from msdn to read the shape and transition text from the visio diagram.
Could anyone help me on the methods which are used to retrieve the shape properties from visio diagram?
 
Joined
Feb 7, 2012
Messages
6
Reaction score
0
The code below cycles through all shapes on a page. It uses several fields in the standard Visio flowchart stencil, so add some data to flowchart shapes in order to try it. See note about referring to the Visio SDK regarding the variations of the Result property.

Code:
Sub ShowShapeData()

    Dim pg As Visio.Page
    Dim shp As Visio.Shape
    
    Set pg = ActivePage
    
    For Each shp In pg.Shapes
        ' shape text
        Debug.Print shp.Text
        ' numeric shape data -- note that the ResultInt() property retrives numeric
        ' data wihtout units conversion; check SDK for other Resultxxxx properties
        If shp.CellExists("Prop.Cost", False) Then
            Debug.Print shp.Cells("Prop.Cost").ResultInt(visNoCast, False)
        End If
        ' string shape data
        If shp.CellExists("Prop.Cost", False) Then
            Debug.Print shp.Cells("Prop.Status").ResultStr(0)
        End If
    Next

End Sub
 

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