简体   繁体   中英

Apply Color to a Specific Word

I'm using Microsoft.Interop.Word to programmatically create a Word document. In a given paragraph, I need to change the font color of the word "Resolved" to green.

I've spent a lot of time searching the internet for how to do this but could not find the solution. Here is the code I'm using to add a paragraph and text:

Microsoft.Office.Interop.Word.Paragraph pgf = document.Paragraphs.Add();
pgf.Range.InsertBefore("Issue Status is Resolved");

Now I want to change the color of "Resolved" to green.

pgf.Range.Words[4].Font.Color = WdColor.wdColorGreen;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM