N Borah
N Borah

Reputation: 11

Format text inside shape in VISO using c#

Hi I wrote this code for a VISIO addin to create shapes and include text in it, here is a part of the code

visioRectShape.Text = "My text";
            visioRectShape.get_CellsSRC((short)Visio.VisSectionIndices.visSectionParagraph,
            (short)Visio.VisRowIndices.visRowFirst, (short)Visio.VisCellIndices.visHorzAlign).FormulaU = "0";

now i want to align this text to top and to the left and format the text to make it bold inside the shape.

with the above code I am able to align it to the left but not able to make it bold or align it to the top. Can someone please help me with this.

Upvotes: 0

Views: 683

Answers (1)

Nikolay
Nikolay

Reputation: 12245

You can use the macro recorder to figure out what operations Visio performs to achieve the formatting you want. To do so, click "Start recording", then perform your operations (set text bold, and align to the top), click "Stop recording", and examine the source code generated by the recorder. You should see something like this:

' bold font
shape.CellsSRC(visSectionCharacter, 0, visCharacterStyle).FormulaU = "1"

' align top
Shape.CellsSRC(visSectionObject, visRowText, visTxtBlkVerticalAlign).FormulaU = "0"

Using C#

// bold font
visioRectShape.get_CellsSRC(
    (short)Visio.VisSectionIndices.visSectionCharacter,
    (short)0, 
    (short)Visio.VisCellIndices.visCharacterStyle).FormulaU = "1";

// align top
visioRectShape.get_CellsSRC(
    (short)Visio.VisSectionIndices.visSectionObject,
    (short)Visio.VisRowIndices.visRowText, 
    (short)Visio.VisCellIndices.visTxtBlkVerticalAlign).FormulaU = "0";

Upvotes: 1

Related Questions