0

我正在尝试使用 Javascript 在我的 Word 插件项目中指定一个段落并替换它。我正在从由 yeoman 生成器生成的模板构建加载项。我正在这样做,但它不起作用,所以我真的不知道我想要实现的目标是否真的可能:

const allParagraphs = context.document.body.paragraphs;
  context.load(allParagraphs, ['items', 'text']);
  return context.sync().then(()=>{

        allParagraphs.items[4].insertParagraph("This is a new paragraph replacing the old one in this location", Word.InsertLocation.replace);


    }
  }).then(context.sync);

如果这不是解决方法,请问正确的做法是什么?我的加载项被设计为支持 Word 2016 及更高版本,因此我使用的最大 API 集停止在支持 Word 2016 的那些上。

4

0 回答 0