2017-04-03 104 views
0

我在将文档文档插入到另一个文档时遇到问题。插入文档后,它会丢失内容控件,因为任何其他操作都是不可能的。请帮助在将word文档插入到文档中后,我在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); 
 
     } 
 
     }); 
 
    }

lossing content control

回答

0

我试图在这两个词的富客户端和字网上API contentcontrol.insertFileFromBase64(, “替换”)。但我无法重现您报告的问题。内容控制不会丢失。你是否仍然可以重新制作它,你可以提供一个简化的repro步骤吗?

+0

它在Word桌面应用程序中正常工作,但在网上字有时它是失去它的内容控制。 – Leo

+0

请检查我已添加的图像。图像第一段有控制权。 – Leo

+0

休息一切都没有控制。 – Leo