Word JavaScript API 修改 Document.Styles 或 Document.ListTemplates collection

Word JavaScript API to modify Document.Styles or Document.ListTemplates collection

我想使用 Word JavaScript API 访问和修改 Document.Styles 或 Document.ListTemplates。

比如在Word中VBA我们可以修改样式的字号为

有效Document.Styles(“标题 1”)。Font.Size= 10

我想通过 JavaScript API 做同样的事情。有办法吗?

为了添加自定义样式,您需要将它们作为 OOXML 插入。您可以使用 body.insertOoxml() function. Once your style is defined in the document, you can apply it to a paragraph or range 对象将 OOXML 插入到文档中。

不幸的是,Office.js 目前不支持您在 VBA 中使用的简化语法。我建议将此添加到 Office UserVoice 以供考虑。