I am working on Word web addin OfficeJS, I wanna change my underline color to red. Is it possible to change the color of underline without affecting the font color ? Attached my code below:
Word.run(function (context) {
var searchResults = context.document.body.search(searchResult, { ignorePunct: true });
context.load(searchResults, 'font');
return context.sync().then(function () {
for (var i = 0; i < searchResults.items.length; i++) {
searchResults.items[i].font.color = 'red';
searchResults.items[i].font.underline = 'wave';
}
return context.sync();
});
})
You have to first create a custom character style with the underline color set to red. Give the style a name. The following code works for me. "StyleZZ" is a character style which specifies an underline font with red underline color. In all other respects it is default font.
Notice that you don't have to load everything on the
searchResults
object, only thestyle
property.