是否可以设置Word文档的自定义属性? [英] Is it possible to set a word documents custom properties?

查看:534
本文介绍了是否可以设置Word文档的自定义属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以基本上我想向Word文档中添加一些自定义属性.

So basically i want to add some custom properties to a word document.

使用api 1.3这个词还可以吗?

Is this possible yet from the word api 1.3?

我发现了一些类似的东西:

I found something along the lines of:

context.document.workbook.properties

但这似乎仅适用于excel.

but that only seems to work for excel.

谢谢!

推荐答案

要为先前的答案添加更多细节:是Word.js 1.3引入了自定义和内置文档属性的创建和检索.该API仍处于预览状态,您至少需要具有12月的fork版本才能使用此功能.确保在16.0.7766+版本上尝试.另外,请确保对Office.js使用我们的预览CDN https://appsforoffice .microsoft.com/lib/beta/hosted/office.js

To add more detail to the previous answer: Yes Word.js 1.3 introduces creation and retrieval of custom and built-in document properties. The API is still in preview, you need to at least have the December fork build for this feature to work. Make sure you try it on 16.0.7766+ builds. Also please make sure to use our Preview CDN for Office.js https://appsforoffice.microsoft.com/lib/beta/hosted/office.js

以下是有关如何在Word中创建自定义属性的代码示例:

Here is a code sample on how to create a custom property in Word:

 function createCustomProperty(){
        Word.run(function (context) {
          //method accepts property name plus value
            context.document.properties.customProperties.add("property_name", 123);
            return context.sync()
            .catch(function (e) {
                console.log(e.message);

            })

        })

    }

查看文档以查看其他功能,包括获取内置属性 https://github.com/OfficeDev/office-js-docs/blob/WordJs_1.3_Openspec/reference/word/documentproperties.md

Check out the documentation to see other functionalities, including getting built-in properties https://github.com/OfficeDev/office-js-docs/blob/WordJs_1.3_Openspec/reference/word/documentproperties.md

希望这会有所帮助, 谢谢! 胡安.

Hope this helps, Thanks! Juan.

这篇关于是否可以设置Word文档的自定义属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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