Highlight random text in Aspose word Dot net

Hi Team,

We have a requirement to highlight text in yellow in word document through dot net code. Say a paragraph have 4 lines and we will have to highlight few words in second line programmatically. Could you please share us a sample code logic to achieve this functionality in Aspose word dot net.

Thanks

@Karthik_Test_account You can use Find/Replace functionality to highlight some specific text in the document. For example the following code highlights "Aspose.Words" in the document with yellow:

Document doc = new Document(@"C:\Temp\in.docx");
FindReplaceOptions options = new FindReplaceOptions();
options.ApplyFont.HighlightColor = Color.Yellow;
options.UseSubstitutions = true;
doc.Range.Replace("Aspose.Words", "$0", options);
doc.Save(@"C:\Temp\out.docx");