Office js 尝试在表行中插入内容控件时发生GeneralException

Office js 尝试在表行中插入内容控件时发生GeneralException,office-js,Office Js,每次尝试在表行中插入ContentControl时,我都会遇到GeneralException。 示例代码: Word.run(async (context) => { let table: Word.Table = context.document.getSelection().parentTable; table.load("rowCount, rows/items/cells/items/body"); await context.sy

每次尝试在表行中插入ContentControl时,我都会遇到GeneralException。 示例代码:

   Word.run(async (context) => {
       let table: Word.Table = context.document.getSelection().parentTable;
       table.load("rowCount, rows/items/cells/items/body");
       await context.sync();

       let rows: Word.TableRowCollection = table.rows;

       for (let i: number = 0; i < rows.items.length; i++) {
           let range: Word.Range = null;
           for (let j: number = 0; j < rows.items[i].cells.items.length; j++){
               if (range == null) {
                   range = rows.items[i].cells.items[j].body.getRange();
               } else {
                   range = range.expandTo(rows.items[i].cells.items[j].body.getRange());
               }
           }
           range.insertContentControl();
       }
       return context.sync();
   }).catch((error) => {
       this.errorEmitter.emit(error);
   });
Word.run(异步(上下文)=>{
let table:Word.table=context.document.getSelection().parentTable;
表1.load(“行数、行/项/单元格/项/正文”);
wait context.sync();
let rows:Word.TableRowCollection=table.rows;
for(设i:number=0;i{
this.errorEmitter.emit(错误);
});
这个错误我只在word在线上看到。在桌面word中,它工作得非常完美。 我做错了什么?

对于这种情况,您的代码应该是正确的。 但是,word online现在不支持表单元格和表行内容控制。这就是为什么你会得到这个例外