How can I change the fill color of selected SVG icon in PowerPoint web add-in using Office.js

Ankit Shrivastava 5 Reputation points
2024-11-29T11:08:10.64+00:00

I'm working on a PowerPoint web add-in using Office.js, and I'm trying to change the fill color of selected shapes in a slide. I wrote the following function to change the color, but it's not working as expected. The SVG icon is coming as an image and hence, I'm not able to change the color of the SVG icon.

async function setFillColor(color) {     await PowerPoint.run(async (context) => {         const selectedShapes = context.presentation.getSelectedShapes();         selectedShapes.load("items");         await context.sync();         await selectedShapes.items.forEach(async (shape) => {             if (color != "") shape.fill.setSolidColor(color);             else shape.fill.clear();         });     }); }
Microsoft 365 and Office | Development | Other
0 comments No comments
{count} votes

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.