different format into one single line Interop.word

前端 未结 6 893
深忆病人
深忆病人 2020-12-11 04:45

I\'ve been trying to figure out how to insert 2 different formats into the same paragraph using interop.word in c# like this:

hello planet earth her

6条回答
  •  轮回少年
    2020-12-11 05:41

    Assuming you have your document defined as oDoc, the following code should get you the desired result:

    Word.Paragraph oPara = oDoc.Content.Paragraphs.Add(ref oMissing);
    oPara.Range.Text = "hello planet earth here's what I want to do";
    object oStart = oPara.Range.Start + 13;
    object oEnd = oPara.Range.Start + 18;
    
    Word.Range rBold = oDoc.Range(ref oStart, ref oEnd);
    rBold.Bold = 1;
    

提交回复
热议问题