diff --git a/samples/word/45-shapes/manage-geometric-shapes.yaml b/samples/word/45-shapes/manage-geometric-shapes.yaml index d9410266..20b86ab8 100644 --- a/samples/word/45-shapes/manage-geometric-shapes.yaml +++ b/samples/word/45-shapes/manage-geometric-shapes.yaml @@ -14,6 +14,8 @@ script: document.getElementById("get-first-geometric-shape").addEventListener("click", () => tryCatch(getFirstGeometricShape)); document.getElementById("get-first-heptagon").addEventListener("click", () => tryCatch(getFirstHeptagon)); document.getElementById("get-first-moon-fill").addEventListener("click", () => tryCatch(getFirstMoonColorFill)); + document.getElementById("clear-first-moon-fill").addEventListener("click", () => tryCatch(clearFirstMoonColorFill)); + document.getElementById("set-first-moon-fill").addEventListener("click", () => tryCatch(setFirstMoonColorFill)); async function insertGeometricShape_Heptagon() { await Word.run(async (context) => { @@ -136,6 +138,56 @@ script: }); } + async function clearFirstMoonColorFill() { + await Word.run(async (context) => { + // Clears the color fill properties of the first moon found in the document body. + const moon: Word.Shape = context.document.body.shapes + .getByGeometricTypes([Word.GeometricShapeType.moon]) + .getFirstOrNullObject(); + moon.load("fill"); + await context.sync(); + + if (moon.isNullObject) { + console.log("No moons found in the document body."); + return; + } + + const moonFill: Word.ShapeFill = moon.fill; + console.log("Current fill properties of the first moon found in the document body:", moonFill); + + moonFill.clear(); + moonFill.load(); + await context.sync(); + + console.log("Cleared the color fill properties of the first moon found in the document body:", moonFill); + }); + } + + async function setFirstMoonColorFill() { + await Word.run(async (context) => { + // Sets color fill properties of the first moon found in the document body. + const moon: Word.Shape = context.document.body.shapes + .getByGeometricTypes([Word.GeometricShapeType.moon]) + .getFirstOrNullObject(); + moon.load("fill"); + await context.sync(); + + if (moon.isNullObject) { + console.log("No moons found in the document body."); + return; + } + + const moonFill: Word.ShapeFill = moon.fill; + console.log("Current fill properties of the first moon found in the document body:", moonFill); + + moonFill.setSolidColor("green"); + moonFill.load(); + await context.sync(); + + console.log("Updated color fill properties of the first moon found in the document body:", moonFill); + }); + } + // Default helper for invoking an action and handling errors. async function tryCatch(callback) { try { @@ -171,8 +223,15 @@ template: +

Work with color fill properties of the first moon

+ + language: html diff --git a/snippet-extractor-metadata/word.xlsx b/snippet-extractor-metadata/word.xlsx index 549f9dd0..996db188 100644 Binary files a/snippet-extractor-metadata/word.xlsx and b/snippet-extractor-metadata/word.xlsx differ diff --git a/snippet-extractor-output/snippets.yaml b/snippet-extractor-output/snippets.yaml index a2f49f4a..a1aed7ba 100644 --- a/snippet-extractor-output/snippets.yaml +++ b/snippet-extractor-output/snippets.yaml @@ -28252,6 +28252,62 @@ Word.ShapeFill:class: console.log(`\tTransparency: ${moonFill.transparency}`); console.log(`\tFill type: ${moonFillType}`); }); +Word.ShapeFill#clear:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/manage-geometric-shapes.yaml + + + await Word.run(async (context) => { + // Sets color fill properties of the first moon found in the document body. + const moon: Word.Shape = context.document.body.shapes + .getByGeometricTypes([Word.GeometricShapeType.moon]) + .getFirstOrNullObject(); + moon.load("fill"); + await context.sync(); + + if (moon.isNullObject) { + console.log("No moons found in the document body."); + return; + } + + const moonFill: Word.ShapeFill = moon.fill; + console.log("Current fill properties of the first moon found in the document body:", moonFill); + + moonFill.setSolidColor("green"); + moonFill.load(); + await context.sync(); + + console.log("Updated color fill properties of the first moon found in the document body:", moonFill); + }); +Word.ShapeFill#setSolidColor:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/manage-geometric-shapes.yaml + + + await Word.run(async (context) => { + // Sets color fill properties of the first moon found in the document body. + const moon: Word.Shape = context.document.body.shapes + .getByGeometricTypes([Word.GeometricShapeType.moon]) + .getFirstOrNullObject(); + moon.load("fill"); + await context.sync(); + + if (moon.isNullObject) { + console.log("No moons found in the document body."); + return; + } + + const moonFill: Word.ShapeFill = moon.fill; + console.log("Current fill properties of the first moon found in the document body:", moonFill); + + moonFill.setSolidColor("green"); + moonFill.load(); + await context.sync(); + + console.log("Updated color fill properties of the first moon found in the document body:", moonFill); + }); Word.ShapeFillType:enum: - >- // Link to full sample: