Search code examples
office-jsoffice-addinsoffice-js-helpers

Customize the Styles of Office Word Context Using Office.js


I want to customize the "Heading1" and "Heading2" styles programatically using Ooxml via office.js library in visual studio code. I have searched through google and many documentations but don't still get anything in that line. Is it possible to achieve this the way I want to? What are the available options if I can't get it done the way I am intending to.

Thanks.


Solution

  • No, it's unfortunately not possible to modify built-in / existing styles using Office-JS.

    1. It's not part of the APIs (at least, not at the time of this writing).
    2. There are restrictions on what run-time OOXML can change in an open Word document, both using Office JS as well as using the COM object model. More specifically, the Word application does not support changing the style definitions of existing styles in an opened document.

    It is possible to change these styles on the closed document, using a library such as the Open XML SDK.

    You might want to add your vote(s) to the suggestion to allow changing styles, numbered list definitions, etc. On UserVoice, where the topic is "under review".