Background Color of a Slide

Simon Paul 20 Reputation points
2025-03-01T21:53:10.83+00:00

How can I get the background color of a slide or the presentation theme? I cannot find such an option in the documentation.
For example, most presentations (including the standard one) have a white bg.
But some have a different color, I want to get this color with an API call.

JavaScript API
JavaScript API
An Office service that supports add-ins to interact with objects in Office client applications.
1,058 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Ilgar Zarbaliyev 26 Reputation points MVP
    2025-03-26T07:00:35.1266667+00:00

    The current Office JavaScript API for PowerPoint (as of now) does not provide a direct way to get the slide background color or theme color through a documented or supported call.

    Not Yet Supported

    Unfortunately, these are not currently accessible:

    • Background color of a slide

    Theme colors or design applied to a presentation

    Master slide styles

    There is no Office.js method like slide.background.color or presentation.theme available right now.

    Workaround Ideas (Limited)

    1. Manually use shapes/layers to infer background

    If your slide background is actually a filled shape, you can access that shape and inspect its fill:

    PowerPoint.run(async (context) => {
      const slides = context.presentation.slides;
      slides.load("items");
    
      await context.sync();
    
      const shapes = slides.items[0].shapes;
      shapes.load("items/fill");
    
      await context.sync();
    
      shapes.items.forEach(shape => {
        console.log("Fill Type:", shape.fill.type); // e.g., "Solid"
        // Unfortunately no color info is exposed yet
      });
    });
    

    But note: this only works if the slide background is created using a shape.


    1. Use Office Add-in to Export Slide as Image and Analyze Color

    This is a hacky workaround:

    Export slide as an image (not available in JS API, but possible via VBA or desktop automation)

    Use color analysis on the exported image to infer background


    1. VBA as Alternative (Desktop only)

    In VBA, you can read theme color and slide background formatting, e.g.:

    Sub GetSlideBackgroundColor()
        Dim slide As slide
        Set slide = ActivePresentation.Slides(1)
        MsgBox slide.FollowMasterBackground  ' True or False
        ' Unfortunately, background color itself is not directly readable
    End Sub
    

    Even in VBA, it’s limited unless the background is explicitly set using shapes or fill formatting.

    0 comments No comments

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.