Ankit Shrivastav
Ankit Shrivastav

Reputation: 1

Change color of svg icon through powerpoint web add-in

I'm developing a PowerPoint web add-in using Office.js and am having difficulty changing the color of an icon inserted into a slide. The icon is in SVG format, but I can't access the required properties of the SVG icon object to modify its color.

Any help or related post will be helpful.

We tried using below code to change the color of the icon which is in SVG format.But the SVG 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();
      }
    });
  });
}

Upvotes: 0

Views: 53

Answers (1)

Raghad PSAU
Raghad PSAU

Reputation: 3

To change the color of an SVG icon in PowerPoint using Office.js, make sure to insert it as an inline shape instead of an image. Once inserted as an inline shape, you can modify properties like color in the SVG.

Upvotes: 0

Related Questions