none
Highlighting a Range of Text at Various Positions in Word RRS feed

  • Question

  • I have a bookmark control that contains some text content. I want to highlight portions of that text, but not all of it. Range.HighlightColorIndex only highlights the entire specified range, so it's not useful for my purposes. I've tried defining new ranges and highlighting them separately, but then I run into issues with overwriting other bookmark controls in the document. Is there a way to do this without messing with other content in the document?

    I am working in C#.

    • Edited by dealing16 Wednesday, February 24, 2016 10:13 PM
    Wednesday, February 24, 2016 10:05 PM

Answers

  • Hi dealing16,

    We could change the range by using Range.SetRange method.

    For example:

    Word.Range r= bookmark1.Range;
                int s = r.Start;
                int e = r.End;
                r.Select();
                r.SetRange(s, e - 2);
                r.Select();

    Regards

    Starain


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, February 25, 2016 7:32 AM
    Moderator