PowerPoint.ShapeFill class

Represents the fill formatting of a shape object.

Extends

Remarks

[ API set: PowerPointApi 1.4 ]

Properties

context

The request context associated with the object. This connects the add-in's process to the Office host application's process.

foregroundColor

Represents the shape fill foreground color in HTML color format, in the form #RRGGBB (e.g., "FFA500") or as a named HTML color (e.g., "orange").

transparency

Specifies the transparency percentage of the fill as a value from 0.0 (opaque) through 1.0 (clear). Returns null if the shape type does not support transparency or the shape fill has inconsistent transparency, such as with a gradient fill type.

type

Returns the fill type of the shape. See PowerPoint.ShapeFillType for details.

Methods

clear()

Clears the fill formatting of this shape.

load(options)

Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.

load(propertyNames)

Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.

load(propertyNamesAndPaths)

Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.

setSolidColor(color)

Sets the fill formatting of the shape to a uniform color. This changes the fill type to Solid.

toJSON()

Overrides the JavaScript toJSON() method in order to provide more useful output when an API object is passed to JSON.stringify(). (JSON.stringify, in turn, calls the toJSON method of the object that is passed to it.) Whereas the original PowerPoint.ShapeFill object is an API object, the toJSON method returns a plain JavaScript object (typed as PowerPoint.Interfaces.ShapeFillData) that contains shallow copies of any loaded child properties from the original object.

Property Details

context

The request context associated with the object. This connects the add-in's process to the Office host application's process.

context: RequestContext;

Property Value

foregroundColor

Represents the shape fill foreground color in HTML color format, in the form #RRGGBB (e.g., "FFA500") or as a named HTML color (e.g., "orange").

foregroundColor: string;

Property Value

string

Remarks

[ API set: PowerPointApi 1.4 ]

transparency

Specifies the transparency percentage of the fill as a value from 0.0 (opaque) through 1.0 (clear). Returns null if the shape type does not support transparency or the shape fill has inconsistent transparency, such as with a gradient fill type.

transparency: number;

Property Value

number

Remarks

[ API set: PowerPointApi 1.4 ]

type

Returns the fill type of the shape. See PowerPoint.ShapeFillType for details.

readonly type: PowerPoint.ShapeFillType | "NoFill" | "Solid" | "Gradient" | "Pattern" | "PictureAndTexture" | "SlideBackground";

Property Value

PowerPoint.ShapeFillType | "NoFill" | "Solid" | "Gradient" | "Pattern" | "PictureAndTexture" | "SlideBackground"

Remarks

[ API set: PowerPointApi 1.4 ]

Method Details

clear()

Clears the fill formatting of this shape.

clear(): void;

Returns

void

Remarks

[ API set: PowerPointApi 1.4 ]

load(options)

Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.

load(options?: PowerPoint.Interfaces.ShapeFillLoadOptions): PowerPoint.ShapeFill;

Parameters

options
PowerPoint.Interfaces.ShapeFillLoadOptions

Provides options for which properties of the object to load.

Returns

load(propertyNames)

Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.

load(propertyNames?: string | string[]): PowerPoint.ShapeFill;

Parameters

propertyNames

string | string[]

A comma-delimited string or an array of strings that specify the properties to load.

Returns

load(propertyNamesAndPaths)

Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.

load(propertyNamesAndPaths?: {
            select?: string;
            expand?: string;
        }): PowerPoint.ShapeFill;

Parameters

propertyNamesAndPaths

{ select?: string; expand?: string; }

propertyNamesAndPaths.select is a comma-delimited string that specifies the properties to load, and propertyNamesAndPaths.expand is a comma-delimited string that specifies the navigation properties to load.

Returns

setSolidColor(color)

Sets the fill formatting of the shape to a uniform color. This changes the fill type to Solid.

setSolidColor(color: string): void;

Parameters

color

string

A string that specifies the fill color in HTML color format, in the form #RRGGBB (e.g., "FFA500") or as a named HTML color (e.g., "orange").

Returns

void

Remarks

[ API set: PowerPointApi 1.4 ]

Examples

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/get-set-shapes.yaml

// Changes the selected shapes fill color to red.
await PowerPoint.run(async (context) => {
  const shapes = context.presentation.getSelectedShapes();
  const shapeCount = shapes.getCount();
  shapes.load("items");
  await context.sync();
  shapes.items.map((shape) => {
    shape.fill.setSolidColor("red");
  });
  await context.sync();
});

toJSON()

Overrides the JavaScript toJSON() method in order to provide more useful output when an API object is passed to JSON.stringify(). (JSON.stringify, in turn, calls the toJSON method of the object that is passed to it.) Whereas the original PowerPoint.ShapeFill object is an API object, the toJSON method returns a plain JavaScript object (typed as PowerPoint.Interfaces.ShapeFillData) that contains shallow copies of any loaded child properties from the original object.

toJSON(): PowerPoint.Interfaces.ShapeFillData;

Returns