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.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…