tompen78
tompen78

Reputation: 13

PowerPoint Office JS Task Pane Addin functionality to copy and paste shape

I must be missing something, but I cannot seem to figure out how to build a simple function to copy and paste a shape in my Office Addin for PowerPoint. Seems there is no support for this. At least not what I can find in the APIs for PowerPoint. Really hope I am missing something obvious here...

The work around I use at the moment is to copy all available attributes of the shapes I want to copy and then add a new shape with the same attributes. This would be fine (even though cumbersome), but only some attributes are accessible (like height, width etc.). Many text / paragraph formatting attributes are still missing.

Hope someone knows a better way to do this! Any support will be greatly appreciated!

error message I receive in ScriptLab:

$("#run").click(run);

function run() {
  Office.context.document.getSelectedDataAsync(Office.CoercionType.XmlSvg, {}, (asyncResult) => {
    if (asyncResult.status === Office.AsyncResultStatus.Failed) {
      //await context.sync();
      console.error(asyncResult);
    } else {
      //await context.sync();
      console.log(asyncResult);
    }
  });
}

Upvotes: 1

Views: 308

Answers (1)

Rick Kirkham
Rick Kirkham

Reputation: 9784

I think this can be done with the Common APIs. Try using document.getSelectedDataAsync and setSelectedDataAsync. The reference for the Common APIs is office package.

Upvotes: 0

Related Questions