2017-04-03 146 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