locked
Microsoft.Office.Interop.Word HiLight Text RRS feed

  • Question

  • User-1471881183 posted

    hi all,

    im using Microsoft.Office.Interop.Word

    at one situation i want to Highlight one word from a sentence so, i used below code

    wrdSelection.TypeText(@"Installation date, as agreed, will be on.");

                wrdApp.Selection.Font.Size = 12;

                wrdApp.Selection.Font.Name = "Arial Narrow";

                wrdApp.Selection.Font.Bold = 1;

    but i dont know how to hilight the text.

    experts please guide me to code this.

    Thursday, January 5, 2012 4:11 AM

All replies

  • User2062822081 posted

    This will highlight all the text in the paragraphs to blue.  You can specific which text you want to be blue in your select code.

    foreach (Paragraph para in doc.Paragraphs)
    {

           para.Range.HighlightColorIndex = Microsoft.Office.Interop.Word.WdColorIndex.wdBlue;

    }

    or for your code:

    wrdApp.Selection.Range.HighlightColorIndex = Microsoft.Office.Interop.Word.WdColorIndex.wdBlue;

    Monday, February 6, 2012 10:55 AM