vbavisioshapesheet

VBA visio - cannot change font size in the element


I am wondering why I see completely no reaction when trying to change the font size of the element.

My code is:

For Each Vshp In VPage.Shapes
    If Vshp.Name Like "*UG*" Then
        Debug.Print Vshp.ID & " - " & Vshp.Master.Name
        Vshp.CellsSRC(visSectionCharacter, 0, visCharacterSize).FormulaU = "12 pt"
    End If
Next

Both approaches from the below links don't work either:

How change the style of a shape-text in vba?

Changing font size in Visio through Visual Basic

enter image description here


Solution

  • You must use Drawing Explorer Window.
    There you cant find page's content in tree-view
    ug

    In this case we can see 4 sub-shapes into UG-shape…
    If you need change font size for sub-shape with text NRTH-X-AF01AK you need change line Vshp.CellsSRC(visSectionCharacter, 0, visCharacterSize).FormulaU = "12 pt" to line Vshp.Shapes(4).CellsSRC(visSectionCharacter, 0, visCharacterSize).FormulaU = "12 pt"