You can resize the font of the text block using automation if the text exceeds the size of the shape. I found that the following works.
Open the shape's shapesheet (Window->Show Shapesheet) and add the user section (Insert->Section->User-defined Cells). Put this formula in the value cell for User.Row_1:
=Min(1,Height/TEXTHEIGHT(TheText,Width)))
After the shape text changes, get the value of the user cell. in c#:
double scale = shape.get_CellsSRC((short)IVisio.VisSectionIndices.visSectionUser, (short)IVisio.VisRowIndices.visRowUser, (short)IVisio.VisCellIndices.visUserValue).ResultIU;
Then set the font, and the TextMargins (for any that are non-zero) with the following (assuming the normal font size is 12 and the left margin is 4pt.:
shape.get_CellsSRC((short)IVisio.VisSectionIndices.visSectionCharacter, 0, (short)IVisio.VisCellIndices.visCharacterSize).FormulaU = (scale*12).ToString() + "pt";
shape.get_CellsSRC((short)IVisio.VisSectionIndices.visSectionObject, (short)IVisio.VisRowIndices.visRowText, (short)IVisio.VisCellIndices.visTxtBlkLeftMargin).FormulaU = (scale * 4).ToString() + "pt";
Best Answer
To accomplish this task, you need to control the Text Block of the shape. The good news is that you have a lot of control over this in Visio.
First, select the Text Block tool (highlighted below) on the Home tab of the Ribbon to get started.
The instructions are for using the tool are here at the online documentation for Visio 2010.
Also, to get the text block working perfectly when shapes are resized you'll need to set the Text Transform section in the ShapeSheet to achieve your desired outcome. The Text transform section controls the size and positioning of the text block.
The Text Transform section is shown below
Additional resources: