2017-08-17 85 views
0

我想使用office js word api在word中添加內容控件。我正在使用insertContentControl方法,但此方法不在文檔末尾或特定插入位置添加。 下面是我的代碼: -在word中使用office js word api插入內容控件

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)); 
      } 
     }); 

而且我要的屬性添加到它一樣的外觀,標籤,標題爲新的內容控件創建

回答

0

按照insertContentControl(的文件),它會換行整個機構作爲內容控制,最終不會添加新的內容控制。如果要添加新的內容控制在外接程序OOXML與它可以插入新的內容控制的API,這是從文檔

https://dev.office.com/reference/add-ins/word/body

相關問題