1

When a search operation is performed on trackedobjects(paragraph) with search options(matchCase/matchWholeWord) always the first instance is returned. this can be confirmed by doing any font color change on returned range.

example paragraph : For matchCase : "Seller shall convey title to the Real Property to Buyer by grant deed in the form of Exhibit "B" attached hereto ("Deed")."

For matchWholeWord : β€œAll rights under this Agreement and the Warrant Certificates are transferable on the books of Holdings to be maintained for such trasfer purpose.”

In the above examples : always the range of 'deed' which is non caps is returned when we search for "Deed" even though matchCase is true and 'transferable' is returned when we search for "transfer" even though matchWholeWord is true.

var parRangeCol = [];
        function createTrackedparagraph() {
        Word.run(function (context) {
            var paraList = context.document.body.paragraphs;
            context.load(paraList, "text");
            return context.sync().then(function () {
                var para = paraList.items[0];
                parRangeCol[0] = para;
                context.trackedObjects.add(para);
            });
        });
    }

    function changeFontColor() {
        textToHighlight = "Deed";
        winstance = 0;
        var para = parRangeCol[0];
        var rangeCol = para.search(textToHighlight, { matchCase: true });
        para.context.load(rangeCol, 'font');
        return para.context.sync().then(function () {
            rangeCol.items[winstance].font.color = 'red';
            para.context.sync().then(function () {
            })
        })
    } 
Manohar
  • 31
  • 1
  • 6
  • I cannot reproduce this. Your code works fine for me when I select a paragraph and assign it to the `para` variable. Perhaps the problem only occurs when the `para` is a trackedobject. Please provide all of the code, including where you make `para` a tracked object and the whole `Word.run`. – Rick Kirkham Apr 18 '20 at 16:56
  • Thanks @RickKirkham, Yes, it happens with trackedObjects only. please see the updated code snippet. – Manohar Apr 19 '20 at 09:17

0 Answers0