0

i hope you can help me. i'm working on a Tool which creates technical drawings from excel data.

some of the desciption boxes on that drawings have sub- or superscriptions.

i've found that article related to word: How to add subscript characters in paragraphs using Word Automation?

but there's the text directly edited, i'm not sure if this is possible when the Text is in a Rectangle / Textbox, for mne it is another object and not directly the page.

here is a codesnippet:

"X" + **unsaturated + "unsat** ≤ " + DataServer.GETPROJECTDATA["Motor"]["Unsaturated commutation reactance " + unsaturated].Last.Value + " %";

the bolded part should be subscripted for example, is there a possibilty to realize this?

thanks alot

Mirko


status: the drop method:

public void drawer(ShapeItem sI, Visio.Master master)
    {
        //drops the shape at position x,y.
        Visio.Shape shape = vPage.Drop(master, (sI.CoordX / 100000), (sI.CoordY / 100000));
        if (master.Name.Equals("Rectangle") || master.Name.Equals("Rechteck"))
        {
            shape.Text = sI.ShapeText;
            shape = StringFormater.formatText(shape, sI.ShapeName);

            shape.LineStyle = "None";
            shape.Style = "None";
        }
    }

and StringFormater.formatText:

protected static Visio.Shape formatText(Microsoft.Office.Interop.Visio.Shape shape, string p)
    {
        String[] seperateWords = shape.Text.Split(' ');
        //MessageBox.Show(string.Join(",",seperateWords));
        Visio.Characters vChars = shape.Characters;
        int start = 0;
        int end = 0;
        if (p.Equals("head"))
        {
            foreach (String s in seperateWords)
            {
                if (s.Equals("Skmin"))
                {
                    vChars.Begin = start + 1;
                    end = start + s.Length;
                    vChars.End = end - 1;
                    vChars.set_CharProps(4, 2);
                }
                if (s.Equals("Skmax"))
                {
                    vChars.Begin = start + 1;
                    end = start + s.Length;
                    vChars.End = end - 1;
                    vChars.set_CharProps(4, 2);
                }
                start += s.Length;
            }
            MessageBox.Show(shape.Text);
        }

        return vChars.Shape;
    }
Community
  • 1
  • 1
Exar666Kun
  • 135
  • 1
  • 18
  • If I correctly read your question, you are asking how to format text in Microsoft Visio programmatically. Here may be a good article: http://blogs.msdn.com/b/visio/archive/2006/08/18/running-with-characters.aspx – Nikolay Jul 14 '15 at 13:13
  • in the end yes, the text in visio should be edited programmatically, but how can i tell the program ok, take the first textbox/rectangle and edit the text in this or that way... (underline, subscript a.s.o.), than take the next box a.s.o., but before editing an existing textbox, why not edit the text befor dropping the textbox (seems more easier to me). – Exar666Kun Jul 14 '15 at 13:20
  • ok for clearance i can add my ShapeObjects: public class ShapeItem { private String masterName = ""; private Double coordY = 0.0; private Double coordX = 0.0; private Double width = 0.0; private Double height = 0.0; private Double angle = 0.0; private String shapeText = ""; my questions is targeted on shapeText (so String formating (if it is possible)), if not i need to edit all textboxes after droping them to the drawing. which as said before seems more complicated (Unless I'm very much mistaken). – Exar666Kun Jul 14 '15 at 13:38
  • You can't change text formatting with string markup in Visio, i.e. there is nothing like wiki or html markup language. Try the link I've posted - it explains how text formatting works in Visio (it is possible to format text, but not with string markup) – Nikolay Jul 14 '15 at 14:03
  • ok thanks for your reply, i've skimmed over the text, but was not sure if it was that i searching for. Now i will have a closer look, after the way i wanted it to realize is not possible. :) – Exar666Kun Jul 14 '15 at 14:15
  • ok if i understood that text correctly, i get my text as visio.char not as string, and with the related fields to character in visio i can format the text, so i'm not able to drop shape.text formated, so i drop shape.text unformated, read it back and alter the formation of the text or even every letter, after dropping it, sounds very complicated because how do i know which textbox is dropped? maybe if i drop them separetly from the shapes. – Exar666Kun Jul 16 '15 at 11:39
  • As you advised me, i got a closer look to the text, additional i found the msdn manual to this, but still i'm not able to edit the text. But even with that help i dont get i correctly i think. this is what i have now: – Exar666Kun Jul 17 '15 at 14:23
  • @Nikolay please have a look at the edited text above, thank you. :-) – Exar666Kun Jul 17 '15 at 14:47

0 Answers0