Skip to content

[PowerPoint] Shape fill color cannot be retrieved for theme colors #6443

@Splines

Description

@Splines

🎈 Environment

  • Platform: PC desktop
  • Host: PowerPoint
  • Office version: 2511 Build 16.0.19426.20218) 64-bit
  • Operating System: Windows 10, Version 22H2

🎈 Current & expected behavior

I insert an SVG in the slide via

Office.context.document.setSelectedDataAsync(preparedSvg, { coercionType: Office.CoercionType.XmlSvg });

Later on, I retrieve the shape fill color of that shape via

shape.fill.load(["foregroundColor"]);
await context.sync();
const color = shape.fill.foregroundColor;

I get a sensible color only I use a color from the "Standard Colors" in the color picker. Select any shade or theme color and the color will be #000000. Expected: the foreground color should hold the correct color.

🎈 Reproduction

You can find the reproduction via Script Lab here. To follow it, do the following:

  • Click on Run, this will insert a predefined SVG into the slide.
  • As expected, the fill color is null at this point (see the console).
  • Now go to Graphics Format -> Graphics Fill and choose a color under the heading "Standard Colors".
  • Then, click away from the object, then click again on the object. The log should show the correct fill color as hex string.
  • Now, repeat this with a color under the heading "Theme Colors". The log will display the color #000000.
powerpoint-shape-fill.mp4

🎈 Context

The context is this repo where I am currently working on an Add-in for PowerPoint that lets the user insert typst formulas. I'd like to detect the shape color even if the user changes it manually, such that I can reuse this color when the user updates the content of a formula.

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions