首页 > 解决方案 > 是否可以使用 MS PowerPoint 插件选择/更新形状/图标/图像属性?

问题描述

在 Script-Lab 的 MS powerpoint office 插件中使用此示例代码,setSelectedDataAsync 能够插入 Svg。

Office.context.document.setSelectedDataAsync(
    getImageAsBase64String(),
    {
      coercionType: Office.CoercionType.XmlSvg,
      imageLeft: 50,
      imageTop: 50,
      imageWidth: 400
    },
    function(asyncResult) {
      if (asyncResult.status === Office.AsyncResultStatus.Failed) {
        console.error(asyncResult.error.message);
      }
    }
  );

注意:getImageAsBase64String() 是一个返回字符串的函数。此处不明确复制。

但是,当我尝试访问插入的 Svg 时,以下代码会引发错误:“不支持指定的强制类型。”

Office.context.document.getSelectedDataAsync(Office.CoercionType.XmlSvg, function (asyncResult) {
    if (asyncResult.status === Office.AsyncResultStatus.Failed) {
      console.error(asyncResult.error.message);
    } else {
      console.log(JSON.stringify(asyncResult.value, null, 4));
    }
  });

我尝试选择图像、图标、Svg、文本等并适当地修改 CoercionType。我只能从我插入的矩形框中成功获取文本。我找不到任何东西来用不同的颜色填充那个文本框。使用 office.js 的 powerpoint 插件的文档非常有限。

我想知道是否可以使用 MS PowerPoint 插件选择/更新形状/图标/图像属性。

标签: office-jsoffice-addinspowerpoint-addins

解决方案


推荐阅读