Reputation: 56
I want to develop an office add in to add image effect to user selected image. but i did not find how to get the image content in the reference.
I have tried getSelectedDataAsync api, but it not work.
Office.context.document.getSelectedDataAsync(Office.CoercionType.Image, function(asyncResult) {
console.log(asyncResult)
});
Console output:
OSF.DDA.AsyncResult {value: undefined, status: 'failed', error: OSF.DDA.Error}
I also tried presentation.getSelectedShapes
api, but it not work either. getSelectedShapes can get the selected shape and i can get the shape type and make sure the shape is an image, but there is no method to get the image content.
PowerPoint.run(function(context) { o = context.presentation.getSelectedShapes().getItemAt(0); o.load(); console.log(o); return context.sync() })
So is there a way to get the image content in office add-in?
Upvotes: 0
Views: 310
Reputation: 1
For Word I use the following code to get the image:
Word.run(async (context) => {
const range = context.document.getSelection();
await context.sync();
const images = range.inlinePictures;
await context.load(images);
await context.sync();
const image = images.items[0];
});
Upvotes: 0