【问题标题】:Is it possible to using Custom Properties (JavaScript API 1.3 for Office)是否可以使用自定义属性(JavaScript API 1.3 for Office)
【发布时间】:2017-02-13 11:19:38
【问题描述】:

我看到了关于custom properties 的MS Office js api 1.3 文档。 但是我无法从 office js 的 word 设置中读取任何自定义属性项。

       `Word.run(function (context) {

            // Create a proxy object for the document.
            var thisDocument = context.document;

            var customProperties = thisDocument.properties.customProperties;

            context.load(customProperties);

            return context.sync().then(function () {
                var getcount = customProperties.getCount();


                console.log(customProperties.items);
                return context.sync().then(function () {
                    console.log(getcount.value);
                });
            });
        })`

customProperties.items 总是返回空数组。我在customProperties 中也找不到set 方法 我的自定义属性显示在此 (https://i.stack.imgur.com/AywDo.png)。

MS Office js api还不支持访问word中的自定义属性吗?

【问题讨论】:

    标签: javascript office-js office-addins


    【解决方案1】:

    CallOfDuty:我认为您的 Office 客户端没有更新版本(您需要 16/0.7766+)。我在最近的构建中运行了您的代码,并且正在使用您完全相同的代码获取自定义属性。因此,请确保您正在进行新的更新,here are some instructions on how to do it

    顺便说一句,我刚刚得到了您的代码的简化版本。希望这会有所帮助!

    function getProperties() { 
        Word.run(function (context) {
            var customDocProps = context.document.properties.customProperties;
            context.load(customDocProps);
            return context.sync()
                .then(function () {
                    console.log(customDocProps.items.length);
                 })
         })
    }

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-06-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-09
      • 2022-12-17
      • 1970-01-01
      相关资源
      最近更新 更多