Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.5k views
in Technique[技术] by (71.8m points)

office js - Is it possible to select/update shape/icons/image properties using MS powerpoint add-in?

Using this sample code in MS powerpoint office add-in from Script-Lab, setSelectedDataAsync is able to insert an 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);
      }
    }
  );

Note: getImageAsBase64String() is a function that returns a string. Not copying here explicitly.

However, when I tried to access the inserted Svg, the following code throws error : "The specified coercion type is not supported."

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));
    }
  });

I have tried selecting images, icons, Svg, text etc. and modifying CoercionType appropriately. I was able to successfully get text only from the rectangular box I inserted. I couldn't find anything to fill that text box with a different color. The documentation for powerpoint add-in using office.js is very limited.

I would like to know if it is possible to select/update shape/icons/image properties using MS powerpoint add-in.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...