question

Sebastian123-7104 avatar image
0 Votes"
Sebastian123-7104 asked JunjieZhu-MSFT edited

Uppercase font in Word JS API

I am looking to apply sentence case, upper case etc to text using the word JS API. The script is as below.

Is there a property to change the font case to capitals etc? I am not sure how to apply toUpperCase() to this script, but I do not think this would be of use because it would remove the underlying capitalisation, making it impossible to return back to its previous case.

Could you please assist?


async function headingOne() {
await Word.run(async (context) => {
let paragraphs = context.document.getSelection().paragraphs;
context.load(paragraphs, 'style, font, text');
await context.sync();
for (i = 0; i < paragraphs.items.length; i++) {
paragraphs.items[i].spaceBefore = 12;
paragraphs.items[i].spaceAfter = 9;
paragraphs.items[i].font.name = 'Times New Roman';
paragraphs.items[i].font.size = 12;
paragraphs.items[i].font.bold = true;
paragraphs.items[i].font.italic = false;
paragraphs.items[i].text.toUpperCase();
}
await context.sync();
});
}

office-js-dev
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

0 Answers