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();         });     }); }
Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
4,050 questions
0 comments No comments
{count} votes

Your answer

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