Im working on a C # program that uses the Microsoft Word 14.0 object library to create a .doc file, add paragraphs to it and save it. There is a small form with a button that describes the actions (see code below). This part has no problems.
Problem:
The current text in the created word file will be as follows:
Some texts beff = 3.0
What I need to do creates a paragraph that internally has subscript characters (in the paragraph above, the letters "eff" should be indexed):

The resulting document will contain about 100 lines, as indicated above, with different characters that are indexed.
I found a way to index the entire paragraph using a string,
paragraph1.Range.Font.Subscript = 1;
but did not find a way to implement it on separate characters.
I also know that Unicode has letters and numbers in alphabetical order, but, unfortunately, Unicode does not have a complete alphabet in substring format, so this is also not an option.
Question: Is there a way to achieve the goal and insert something like "eff" in the index inside a paragraph in a newly created Word Document?
Code example:
private void btnReport_Click(object sender, EventArgs e) { Word._Application oWord; Word._Document oDoc; oWord = new Word.Application(); oDoc = oWord.Documents.Add(); var paragraph1 = oDoc.Content.Paragraphs.Add(); paragraph1.Range.Text = "Some text beff = 3.0"; SaveFileDialog saveFileDialog1 = new SaveFileDialog(); saveFileDialog1.Filter = "Word document|*.doc"; saveFileDialog1.Title = "Save the Word Document"; if (DialogResult.OK == saveFileDialog1.ShowDialog()) { string docName = saveFileDialog1.FileName; if (docName.Length > 0) { object oDocName = (object)docName; oDoc.SaveAs(ref oDocName); } } oWord.Quit(); }
source share