Office (Word) programming, Highlighting text range in Word document

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • athirukk
    New Member
    • Mar 2009
    • 3

    Office (Word) programming, Highlighting text range in Word document

    Hi,
    I am doing Office (Word) programming in .Net with Microsoft.Offic e.Interop.Word.

    My C# code highlights the a text range in a Word document with the following snippet.

    MyFoundRange.Hi ghlightColorInd ex =
    Microsoft.Offic e.Interop.Word. WdColorIndex.wd Blue;
    MyFoundRange.Fo nt.ColorIndex =
    Microsoft.Offic e.Interop.Word. WdColorIndex.wd White;

    Once I go to the next item to highlight, the previously highlighted text range
    should go back to its original font color and its own format (removing highlight).

    Considering my range has two words, one in custom selected blue color and
    the other word in custom selected green color. After I move away from the selection with the above code, the range should show the same text before it got highlighted. I tried applying wdAuto which is making the selected range to black color text.

    How do I do this?
Working...