使用office js word在word中插入内容控件api
Inserting the content control in word using office js word api
我想用office js word在word中添加内容控件api。我正在使用 insertContentControl 方法,但此方法未在文档末尾或特定插入位置添加。
下面是我的代码:-
Word.run(function (context) {
var body = context.document.body;
var contents = body.contentControls;
// Queue a commmand to wrap the body in a content control.
var a = body.insertContentControl();
a.appearance = "name";
a.tag = "name1";
a.title = "name";
return context.sync().then(function () {
// context.load(body);
console.log('Wrapped the body in a content control.');
});
})
.catch(function (error) {
console.log('Error: ' + JSON.stringify(error));
if (error instanceof OfficeExtension.Error) {
console.log('Debug info: ' + JSON.stringify(error.debugInfo));
}
});
我还想将外观、标签、标题等属性添加到创建的新内容控件中
根据 insertContentControl() 的文档,它将整个主体包装为内容控件,最后不会添加新的内容控件。这是来自文档
https://dev.office.com/reference/add-ins/word/body
如果您想在加载项中添加新的内容控件,您可以使用 ooxml api 插入新的内容控件。
我想用office js word在word中添加内容控件api。我正在使用 insertContentControl 方法,但此方法未在文档末尾或特定插入位置添加。 下面是我的代码:-
Word.run(function (context) {
var body = context.document.body;
var contents = body.contentControls;
// Queue a commmand to wrap the body in a content control.
var a = body.insertContentControl();
a.appearance = "name";
a.tag = "name1";
a.title = "name";
return context.sync().then(function () {
// context.load(body);
console.log('Wrapped the body in a content control.');
});
})
.catch(function (error) {
console.log('Error: ' + JSON.stringify(error));
if (error instanceof OfficeExtension.Error) {
console.log('Debug info: ' + JSON.stringify(error.debugInfo));
}
});
我还想将外观、标签、标题等属性添加到创建的新内容控件中
根据 insertContentControl() 的文档,它将整个主体包装为内容控件,最后不会添加新的内容控件。这是来自文档
https://dev.office.com/reference/add-ins/word/body
如果您想在加载项中添加新的内容控件,您可以使用 ooxml api 插入新的内容控件。