Reputation: 1079
I need to change the size of the first X characters for my add-in. To do this, I should either be able to go through the individual characters or format the first X characters in one go. But I can't find a way to access the individual characters in a Word.Range
that works on the web and also on the desktop. So far it only works via the search
method. Have I overlooked something?
// slow performance
const charRangeCollection = word.search("*", {
matchWildcards: true,
matchCase: false,
ignoreSpace: true,
ignorePunct: true,
matchPrefix: false,
matchSuffix: false,
matchWholeWord: false,
});
This does not work with Word under Windows.
const wordChar = wordRange.getRange().split([""]);
Uncaught (in promise) RichApi.Error: InvalidArgument
In this answer they write getTextRanges() no longer accepts empty strings, but I don't know what to pass so that I only get the characters of one word -> How to get a range from start & end index with Office.js while developing MS Word Add-in
Upvotes: 0
Views: 66
Reputation: 122
Sorry for the inconvenience. There is no other way currently. We open an internal bug #8831269 for the "Range.split([""])" consistency issues between Word Windows and Online. Thanks.
Upvotes: 2