How do you put the text of a different format into the word of annex C#?



  • I cannot enter the text of a different format into the word of annex C#. That's the code I have:

    Word._Application word_app = new Word.Application();
    word_app.Visible = true;
    object missing = Type.Missing;
    Word._Document word_doc = word_app.Documents.Add(ref missing, ref missing, ref missing, ref missing);
    Word.Paragraph para = word_doc.Paragraphs.Add(ref missing);
    para.Range.Text = "Chrysanthemum Curve";
    

    The result is the opening of the word, and the entry into the first line of Chrysanthemum Curve. The problem is, I can't figure out how to add the next line.

    Appendix 2:

    Word.Paragraph para2=word_doc.Paragraphs.Add(ref missing);
    para2.Range.Text = "Text 2";
    

    The communication does not directly alter the current text and does not add a new block.

    word_doc.Paragraphs[0].Range.Text = "Text 1";
    word_doc.Paragraphs[1].Range.Text = "Text 2";
    


  • In fact, it is:

    A document is originally being created.

    Word._Application word_app = new Word.Application();
    word_app.Visible = true;
    object missing = Type.Missing;
    Word._Document word_doc = word_app.Documents.Add(ref missing, ref missing, ref missing, ref missing);
    

    We're adding a text block.

    Word.Paragraph para = word_doc.Paragraphs.Add(ref missing);
    

    No matter how many times we've done

    para = word_doc.Paragraphs.Add(ref missing);
    

    The number of blocks will increase and para refer to the first block.

    3 blocks must be added 4 times

     word_doc.Paragraphs.Add(ref missing);
     word_doc.Paragraphs.Add(ref missing);
     word_doc.Paragraphs.Add(ref missing);
     word_doc.Paragraphs.Add(ref missing);
    

    and then apply to everyone separately, the numbering as I understand begins with 1.

    word_doc.Paragraphs[1].Range.Text = "Text 1";
    word_doc.Paragraphs[2].Range.Text = "Text 2";
    word_doc.Paragraphs[3].Range.Text = "Text 3";
    



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2