是否可以使用自定义属性(适用于Office的JavaScript API 1.3) [英] Is it possible to using Custom Properties (JavaScript API 1.3 for Office)

查看:58
本文介绍了是否可以使用自定义属性(适用于Office的JavaScript API 1.3)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到了有关自定义属性. 但是我无法通过Office js从单词设置中读取任何自定义属性项.

I saw the MS Office js api 1.3 document about custom properties. But I can not read any custom property item from word settings by office js.

       `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 ).

The customProperties.items alway return empty array. I also can not find the set method in customProperties My custom property is show in this (https://i.stack.imgur.com/AywDo.png).

MS Office js API是否还不支持访问Word中的自定义属性?

Does MS Office js api not support to access custom properties in word yet?

推荐答案

CallOfDuty:我认为这是因为您没有Office Client的更新版本(您需要16/0.7766 +).我在最近的版本中运行了您的代码,并使用与您完全相同的代码来获取自定义属性.因此,请确保您正在进行全新更新,这里有一些操作说明.

CallOfDuty: I think what's happening is that you don't have an updated version of your Office Client (you need 16/0.7766+). I ran your code in a recent build and I am getting the custom properties using your exact same code. So just please make sure you are working on a fresh update, here are some instructions on how to do it.

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

Btw, I just got a simplified version of your code. Hope this helps!

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);
             })
     })
}

这篇关于是否可以使用自定义属性(适用于Office的JavaScript API 1.3)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆