首页 > 解决方案 > 使用 Office.js for Office 2013 for Desktop 修改 Office 文档的属性,例如作者

问题描述

我正在使用 office.js 开发 Microsoft Office 插件,针对 Windows 和 Mac。

其中一项要求是修改作者和标签等属性。根据文档主机(Excel、Word 等),特定 API 具有 DocumentProperty 类,可以通过context.document.properties.title如下所示访问它的属性,

Word.run(function (context) {
    var document = context.document;
    document.properties.load("author, title");

    return context.sync()
        .then(function () {
            console.log("The author of this document is " + document.properties.author + " and the title is '" + document.properties.title + "'");
        });
});
}

来源:stackoverflow文档

但是这个 API 属于 WordApi 1.3 要求集,即最早支持的版本是 Office 2019。

所以我的问题是 - 有没有办法使用通用 API 或主机特定 API 来执行此操作,这些 API 属于要求集 WordApi 1.1,支持适用于 Windows 的 Office 2013 和适用于 Mac 的 Office 2011 很重要。如果不是,那么确保加载项在最多主机上工作的最接近的解决方案是什么。

标签: ms-officeoffice-jsadd-in

解决方案


推荐阅读