简体   繁体   中英

Get the current selection on PowerPoint Add-In

I'm developing a Add-in for PowerPoint that inserts images in the document. I'm currently able to insert the image, but what I'm not able to do is to replace a current selected image.

So, for example, imagine that:

  1. The user added an image available on the Add-in, inside an empty slide
  2. He then selected this image and wants to replace it with another one also available on the Add-in.
  3. He clicks/selects the slide image, and then clicks on the image inside the Add-in that he wants to replace.

The thing is that I'm not able to get his selection with the Office API. Can someone help me?

My current code looks like this:

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

Try to use the getSelectedDataAsync method which reads the data contained in the current selection in the document.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM