是否可以设置word文档的自定义属性?
Is it possible to set a word documents custom properties?
所以基本上我想向 word 文档添加一些自定义属性。
从 api 1.3 这个词来看这可能吗?
我发现了一些类似的东西:
context.document.workbook.properties
但这似乎只适用于 excel。
谢谢!
Word API 1.3引入了documentProperties和customProperty,但状态仍列为Preview,需要Word 2016 Desktop Version 1605(Build 6925.1000)或更高版本或移动应用程序(尚未上线)。
为之前的答案添加更多细节:是 Word.js 1.3 引入了自定义和 built-in 文档属性的创建和检索。 API 仍处于预览阶段,您至少需要拥有 12 月的 fork 版本才能使用此功能。确保在 16.0.7766+ 版本上尝试它。另外请确保使用我们的预览 CDN Office.js https://appsforoffice.microsoft.com/lib/beta/hosted/office.js
以下是有关如何在 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);
})
})
}
查看文档以查看其他功能,包括获取 built-in 属性
https://github.com/OfficeDev/office-js-docs/blob/WordJs_1.3_Openspec/reference/word/documentproperties.md
希望这对您有所帮助,
谢谢!
娟.
所以基本上我想向 word 文档添加一些自定义属性。
从 api 1.3 这个词来看这可能吗?
我发现了一些类似的东西:
context.document.workbook.properties
但这似乎只适用于 excel。
谢谢!
Word API 1.3引入了documentProperties和customProperty,但状态仍列为Preview,需要Word 2016 Desktop Version 1605(Build 6925.1000)或更高版本或移动应用程序(尚未上线)。
为之前的答案添加更多细节:是 Word.js 1.3 引入了自定义和 built-in 文档属性的创建和检索。 API 仍处于预览阶段,您至少需要拥有 12 月的 fork 版本才能使用此功能。确保在 16.0.7766+ 版本上尝试它。另外请确保使用我们的预览 CDN Office.js https://appsforoffice.microsoft.com/lib/beta/hosted/office.js
以下是有关如何在 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);
})
})
}
查看文档以查看其他功能,包括获取 built-in 属性 https://github.com/OfficeDev/office-js-docs/blob/WordJs_1.3_Openspec/reference/word/documentproperties.md
希望这对您有所帮助, 谢谢! 娟.