无法从 Office 365 Word Online 中的 Word 表检索内容控件

问题描述 投票:0回答:1

我们有一个产品支持O365 windows和mac使用office js。现在在同一产品上,我们将支持 O365 word 在线。 在工作过程中,我们发现O365 windows和word online存在一处差异。我们有一个文档,其内容控件内有一个单词表。

在Word Online中,我们无法检索Word表格内的内容控件,但是,我们可以检索O365 Windows和Mac桌面中的所有内容控件。

以下代码片段在 O365 窗口和 mac 中正常工作,但在 Word Online 中不起作用。

$("#run").click(() => tryCatch(run));

function run() {
  return Word.run(function (context) {
    var contentControls = context.document.contentControls
    context.load(contentControls, "id,text,title,tag,placeholderText");

   return context.sync().then(function () {
      /*console.log('The selected text was "' + contentControls.items.length + '".');*/
      contentControls.items.forEach((contentControl: Word.ContentControl) => {
        console.log('The Content control id "' + contentControl.id + '".');            
      });
    });
  });
}

/** Default helper for invoking an action and handling errors. */
function tryCatch(callback) {
  Promise.resolve()
    .then(callback)
    .catch(function (error) {
      // Note: In a production add-in, you'd want to notify the user through your add-in's UI.
      console.error(error);
    });
}
javascript office365 office-js office-addins word-contentcontrol
1个回答
0
投票

现在有了最新的API,我可以使用相同的代码从表格中获取富文本内容控件。

Office JS API 仅支持富文本内容控件类型。

© www.soinside.com 2019 - 2024. All rights reserved.