【问题标题】:How to add an image to a slide如何将图像添加到幻灯片
【发布时间】:2019-10-08 11:29:06
【问题描述】:

我正在开发 PowerPoint 加载项。我想在幻灯片中添加图片。

我正在使用带有 TypescriptAngular 框架作为插件,并使用 Yeoman Office 生成器生成插件。

这是我点击按钮时调用的函数。

async addImage() {
    console.log('addImage')
    
    Office.context.document.setSelectedDataAsync("addImage",
      {
        coercionType: Office.CoercionType.Text,
      },
      result => {
        if (result.status === Office.AsyncResultStatus.Failed) {
          console.error(result.error.message);
        }
      }
    );

  }

它添加文本。我想替换它,以便它可以添加图像。

【问题讨论】:

  • 显示代码,或您尝试完成的一些其他尝试。没有它,我们不知道你到底想要什么。
  • 你能分享你的代码吗?你的代码哪里有问题?你可以做一个最低限度的工作demo

标签: angular vba typescript powerpoint office-addins


【解决方案1】:

经过一番硬核搜索,我找到了答案。我必须使用 base64 字符串并将其添加到 PowerPoint 中,如下所示:

async addImage(imgHTML) {
    console.log('addImage')

    Office.context.document.setSelectedDataAsync('addBase64StringHere', 
      { 
        coercionType: Office.CoercionType.Image, 
      },
      result => {
        if (result.status === Office.AsyncResultStatus.Failed) {
          console.error(result.error.message);
        }
      }
    );

  }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-05-04
    • 2016-08-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多