Search code examples
vbavisioshapesheet

Set Container font size using Visio VBA


I have code that is generating containers for a VBA diagram. I need to specify the font size for each container from VBA. For container shape con, I'm trying:

con.Cells("Char.Size").FormulaForceU = "8 pt"

This will cause the font size drop-down in the Visio UI to update to 8pt as well as the cell value in the shape sheet. but it does not actually change the font size for the container. I can change the size manually without issue.

Is there a step I am missing here?


Solution

  • Container shape consist of some sub-shapes!
    In this example you can see into pair of sub-shapes. Each of them have own single sub-shape…
    MS Visio. Container's anathomy Usually container have into 4-5 sub-shapes summary.

    You must define structure of your container, and find index of 'Header' shape

    con.Shapes(2).Cells("Char.Size").FormulaForceU = "8 pt"
    

    This example for sub-shape with index = 2.


    This will cause the font size drop-down in the Visio UI to update to 8pt as well as the cell value in the shape sheet.

    When you use UI changes apply for container and all sub-shapes. But via ShapeSheet you can change only single (active) shape!