我在将word文档插入另一个文档时遇到问题。插入后,它会丢失内容控件,因为任何其他操作都是不可能的。请帮助
function insertDocwit(response,contentControlId)
{
// console.log("dfdff");
// // Run a batch operation against the Word object model.
var deferred = $q.defer();
Word.run(function (context) {
// Create a proxy object for the content controls collection that contains a specific tag.
var contentControlsWithTag = context.document.contentControls.getByTag(contentControlId);
// Queue a command to load the text property for all of content controls with a specific tag.
context.load(contentControlsWithTag, 'text');
// Synchronize the document state by executing the queued commands,
// and return a promise to indicate task completion.
return context.sync().then(function () {
appData.isContentLoaded = true;
if (contentControlsWithTag.items.length === 0) {
console.log("There isn't a content control with the tag");
ngNotify.set("Content Control with the tag is not Found","error");
deferred.resolve();
} else {
//console.log('The first content control with the tag of Customer-Address has this text:');
for (var i = 0;i < contentControlsWithTag.items.length;i++)
contentControlsWithTag.items[i].insertFileFromBase64(response, 'Replace');
deferred.resolve();
}
return deferred.promise;
});
})
.catch(function (error) {
appData.isContentLoaded = true;
var catchedError = JSON.stringify(error.message);
if (catchedError == '"'+'ooxmlIsMalformated'+'"'){
ngNotify.set('The Document which you Selected to Insert is Incompatible with this Document', 'error');
}
if (error instanceof OfficeExtension.Error) {
console.log('Debug info: ' + error.debugInfo);
}
});
}
&#13;
答案 0 :(得分:0)
我尝试了word富客户端和在线word API contentcontrol.insertFileFromBase64(,“替换”)。但我无法重现您报道的问题。内容控件并没有丢失。您是否仍然能够重复它,您能提供简化的重复步骤吗?