[英]Underline Color Word Web Add-in without Font Color
我正在使用 Word 網絡插件 OfficeJS,我想將下划線顏色更改為紅色。 是否可以在不影響字體顏色的情況下更改下划線的顏色? 下面附上我的代碼:
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();
});
})
您必須首先創建一個自定義字符樣式,並將下划線顏色設置為紅色。 為樣式命名。 以下代碼對我有用。 “StyleZZ”是一種字符樣式,它指定帶有紅色下划線顏色的下划線字體。 在所有其他方面,它是默認字體。
var searchResults = context.document.body.search(searchResult, { ignorePunct: true });
searchResults.load("style");
return context.sync().then(function () {
for (var i = 0; i < searchResults.items.length; i++) {
searchResults.items[i].style = "StyleZZ";
}
return context.sync();
});
請注意,您不必加載searchResults
對象上的所有內容,只需加載style
屬性。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.