Search code examples
vbaadd-invisiocustom-properties

Custom property Visio - VBA


First of all, I'm a newbie in VBA, and I'm trying to write some scripts for existing Visio document for automation purposes.

I see that my Visio file has objects with custom properties, and I want to play with those custom properties. (I know that seperate add-in is written for custom properties.)

Here I took a screenshot in my Visio file to show how Custom properties menu look like. This menu is accessed via custom add-in in Visio file.

enter image description here

Based on research, I wrote a simple macro as you see below. For testing purposes I added shp.Name which works fine but shp.CellsU("Prop.Type").ResultStr("") fails.

I want to access and update custom properties of my shape as you see above.

My script file:

Sub Macro4()
    Dim doc As Visio.Document
    Dim pge As Visio.Page
    Dim shp As Visio.Shape
       
    For Each doc In Application.Documents
        'Debug.Print "* " & doc.Name
        For Each pge In doc.Pages
            'Debug.Print "....s* " & pge.Name
            If pge = "134-1" Then
                For Each shp In pge.Shapes
                    Debug.Print "........* " & shp.Name
                    Debug.Print "........* " & shp.CellsU("Prop.Type").ResultStr("") 
                Next shp   
            End If      
       Next pge
    Next doc
End Sub

If you help me with these, I would be appreciated!


Solution

  • At your picture we can see properties Labels (1st row), not their real Names (2nd row) ! Names vs Labels Please check property Name!