Fill a property on shapes by vba code - Visio 2016

Started by ltaretti, February 15, 2018, 05:09:08 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ltaretti

Hey guys, Im on a new project in my company and I need to make some things in Visio 2016.

I want to write a vba code that create a property in shape data and then fill it with the container's shape name. Is there possible?

Ive already wrote a code that create a property "Setor" in all shapes on the page, but I need to fill this property with the name of a container the shapes are into.

The code that Im using is this:

Private Sub Setorizacao()

Dim visShape As Visio.shape
Dim visPage  As Visio.Page



Set visPage = ActivePage

For Each visShape In ActivePage.Shapes
   
   If visShape.CellExists("LockWidth", False) Then
   
   Call InitSetor(visShape)
   
   End If
   
   Next
   
   
           
End Sub

Sub InitSetor(ByRef shape As Visio.shape)

' Create Prop.Setor if they don't exist; set both fields to null

    If Not shape.CellExistsU("Prop.Setor", False) Then
        shape.AddNamedRow visSectionProp, "Setor", visTagDefault
    End If
    shape.CellsU("Prop.Setor").FormulaU = ""
    shape.CellsU("Prop.Setor.Label").FormulaU = Chr(34) & "Setor" & Chr(34)
   
   
End Sub



Thank you in advance.


ltaretti

Thanks for ur response Yacine.

I tryied it by vba code and by shapesheet's formulae on the link but I still cant doing it

I'll try to explain it better.

My code insert a prop "Setor" in all shapes on the page, but all those shapes are in two different containers "SETOR 1" and "SETOR 2", so I want to fill the prop "Setor" with the container's name.
Shapes in container "SETOR 1" fill the prop "Setor" with "SETOR 1"
Shapes in container "SETOR 2" fill the prop "Setor" with "SETOR 2"