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 () {
})
})
}