diff --git a/playlists-prod/powerpoint.yaml b/playlists-prod/powerpoint.yaml
index 910edb0a..1864b779 100644
--- a/playlists-prod/powerpoint.yaml
+++ b/playlists-prod/powerpoint.yaml
@@ -186,4 +186,4 @@
https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/text/get-set-textrange.yaml
group: Text
api_set:
- PowerPointApi: '1.5'
\ No newline at end of file
+ PowerPointApi: '1.8'
\ No newline at end of file
diff --git a/playlists/powerpoint.yaml b/playlists/powerpoint.yaml
index 810bc5be..46985f3b 100644
--- a/playlists/powerpoint.yaml
+++ b/playlists/powerpoint.yaml
@@ -186,4 +186,4 @@
https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/powerpoint/text/get-set-textrange.yaml
group: Text
api_set:
- PowerPointApi: '1.5'
+ PowerPointApi: '1.8'
diff --git a/samples/powerpoint/shapes/get-set-shapes.yaml b/samples/powerpoint/shapes/get-set-shapes.yaml
index 521242f6..789c7262 100644
--- a/samples/powerpoint/shapes/get-set-shapes.yaml
+++ b/samples/powerpoint/shapes/get-set-shapes.yaml
@@ -53,7 +53,7 @@ script:
shape2.load("id");
await context.sync();
- console.log(`IDs: ${shape1.id}, ${shape2.id}`)
+ console.log(`IDs: ${shape1.id}, ${shape2.id}`);
slide1.setSelectedShapes([shape1.id, shape2.id]);
await context.sync();
});
@@ -64,9 +64,11 @@ script:
await PowerPoint.run(async (context) => {
const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes();
const shapeCount = shapes.getCount();
- shapes.load("items");
+ shapes.load("items/fill/type");
await context.sync();
shapes.items.map((shape) => {
+ const shapeFillType = shape.fill.type as PowerPoint.ShapeFillType;
+ console.log(`Shape ID ${shape.id} original fill type: ${shapeFillType}`);
shape.fill.setSolidColor("red");
});
await context.sync();
@@ -115,9 +117,7 @@ script:
}
function generateRandomHexColor() {
- return `#${Math.random()
- .toString(16)
- .substring(2, 8)}`;
+ return `#${Math.random().toString(16).substring(2, 8)}`;
}
async function createShapes() {
@@ -131,7 +131,7 @@ script:
const minNewShapeHeight = 50;
for (let i = 0; i < 20; i++) {
const rectangle: PowerPoint.Shape = currentSlide.shapes.addGeometricShape(
- PowerPoint.GeometricShapeType.rectangle
+ PowerPoint.GeometricShapeType.rectangle,
);
rectangle.height = getRandomBetween(minNewShapeWidth, maxNewShapeWidth);
rectangle.width = getRandomBetween(minNewShapeHeight, maxNewShapeHeight);
diff --git a/samples/powerpoint/shapes/shapes.yaml b/samples/powerpoint/shapes/shapes.yaml
index 68c8d5c3..d830e989 100644
--- a/samples/powerpoint/shapes/shapes.yaml
+++ b/samples/powerpoint/shapes/shapes.yaml
@@ -6,7 +6,7 @@ host: POWERPOINT
api_set:
PowerPointApi: '1.4'
script:
- content: |-
+ content: |
document.getElementById("create-hexagon").addEventListener("click", () => tryCatch(createHexagon));
document.getElementById("shrink-hexagon").addEventListener("click", () => tryCatch(shrinkHexagon));
document.getElementById("move-hexagon").addEventListener("click", () => tryCatch(moveHexagon));
@@ -25,7 +25,7 @@ script:
left: 100,
top: 100,
height: 150,
- width: 150
+ width: 150,
};
const hexagon: PowerPoint.Shape = shapes.addGeometricShape(PowerPoint.GeometricShapeType.hexagon, shapeOptions);
hexagon.name = "Hexagon";
@@ -69,13 +69,12 @@ script:
// For a line, left and top are the coordinates of the start point,
// while height and width are the coordinates of the end point.
- const line: PowerPoint.Shape = shapes.addLine(PowerPoint.ConnectorType.straight,
- {
- left: 400,
- top: 200,
- height: 20,
- width: 150
- });
+ const line: PowerPoint.Shape = shapes.addLine(PowerPoint.ConnectorType.straight, {
+ left: 400,
+ top: 200,
+ height: 20,
+ width: 150,
+ });
line.name = "StraightLine";
await context.sync();
@@ -88,13 +87,12 @@ script:
// location, and size. Then it names the text box.
await PowerPoint.run(async (context) => {
const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes;
- const textbox: PowerPoint.Shape = shapes.addTextBox("Hello!",
- {
- left: 100,
- top: 300,
- height: 300,
- width: 450
- });
+ const textbox: PowerPoint.Shape = shapes.addTextBox("Hello!", {
+ left: 100,
+ top: 300,
+ height: 300,
+ width: 450,
+ });
textbox.name = "Textbox";
return context.sync();
@@ -109,15 +107,17 @@ script:
await PowerPoint.run(async (context) => {
const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes;
const braces: PowerPoint.Shape = shapes.addGeometricShape(PowerPoint.GeometricShapeType.bracePair, {
- left: 100,
- top: 400,
- height: 50,
- width: 150
- });
+ left: 100,
+ top: 400,
+ height: 50,
+ width: 150,
+ });
braces.name = "Braces";
braces.textFrame.textRange.text = "Shape text";
braces.textFrame.textRange.font.color = "purple";
+ braces.textFrame.textRange.font.underline = PowerPoint.ShapeFontUnderlineStyle.heavy;
braces.textFrame.verticalAlignment = PowerPoint.TextVerticalAlignment.middleCentered;
+ braces.textFrame.autoSizeSetting = PowerPoint.ShapeAutoSize.autoSizeShapeToFitText;
return context.sync();
});
diff --git a/samples/powerpoint/text/get-set-textrange.yaml b/samples/powerpoint/text/get-set-textrange.yaml
index f18a6bea..810332ba 100644
--- a/samples/powerpoint/text/get-set-textrange.yaml
+++ b/samples/powerpoint/text/get-set-textrange.yaml
@@ -4,14 +4,17 @@ name: Work with text range selections
description: Get, set, load, and save text range selections.
host: POWERPOINT
api_set:
- PowerPointApi: '1.5'
+ PowerPointApi: '1.8'
script:
- content: |-
+ content: |
document.getElementById("getSelectedTextRange").addEventListener("click", () => tryCatch(getSelectedTextRange));
document.getElementById("setSelectedTextRange").addEventListener("click", () => tryCatch(setSelectedTextRange));
document.getElementById("changeColor").addEventListener("click", () => tryCatch(changeColor));
document.getElementById("saveTextSelection").addEventListener("click", () => tryCatch(saveTextSelection));
document.getElementById("loadTextSelection").addEventListener("click", () => tryCatch(loadTextSelection));
+ document
+ .getElementById("getSelectedTextRangeProperties")
+ .addEventListener("click", () => tryCatch(getSelectedTextRangeComplexProperties));
async function getSelectedTextRange() {
// Gets the selected text range and prints data about the range on the task pane.
@@ -37,7 +40,7 @@ script:
txtExplained = txtExplained.replace(/\v/g, "VV");
let finalTable = "";
finalTable +=
- "
| Index | Id |
";
+ "| Index | Id |
";
finalTable += "| Raw | " + textRange.text + " |
";
finalTable += "| Html | " + txtHtml + " |
";
finalTable += "| Exp | " + txtExplained + " |
";
@@ -45,7 +48,7 @@ script:
finalTable += "| Length | " + textRange.length + " |
";
finalTable += "
";
const outputSpan = document.getElementById("outputSpan");
- outputSpan.innerHTML = ""
+ outputSpan.innerHTML = "";
outputSpan.innerHTML += finalTable;
});
}
@@ -132,12 +135,42 @@ script:
await PowerPoint.run(async (context) => {
const slide1: PowerPoint.Slide = context.presentation.slides.getItem(savedTextSlideSelection[0]);
const shape1: PowerPoint.Shape = slide1.shapes.getItem(savedTextShapeSelection[0]);
- const textRange: PowerPoint.TextRange = shape1.textFrame.textRange.getSubstring(savedTextTextRangeStart, savedTextTextRangeLength);
+ const textRange: PowerPoint.TextRange = shape1.textFrame.textRange.getSubstring(
+ savedTextTextRangeStart,
+ savedTextTextRangeLength,
+ );
textRange.setSelected();
await context.sync();
});
}
+ async function getSelectedTextRangeComplexProperties() {
+ // Gets navigational (complex) properties of the selected text range.
+ await PowerPoint.run(async (context) => {
+ const textRange: PowerPoint.TextRange = context.presentation.getSelectedTextRange();
+ textRange.load("font,paragraphFormat/bulletFormat,paragraphFormat/horizontalAlignment");
+ await context.sync();
+
+ console.log("Font properties of selected text range:");
+ console.log(`\tallCaps: ${textRange.font.allCaps}`);
+ console.log(`\tbold: ${textRange.font.bold}`);
+ console.log(`\tcolor: ${textRange.font.color}`);
+ console.log(`\tdoubleStrikethrough: ${textRange.font.doubleStrikethrough}`);
+ console.log(`\titalic: ${textRange.font.italic}`);
+ console.log(`\tname: ${textRange.font.name}`);
+ console.log(`\tsize: ${textRange.font.size}`);
+ console.log(`\tsmallCaps: ${textRange.font.smallCaps}`);
+ console.log(`\tstrikethrough: ${textRange.font.strikethrough}`);
+ console.log(`\tsubscript: ${textRange.font.subscript}`);
+ console.log(`\tsuperscript: ${textRange.font.superscript}`);
+ console.log(`\tunderline: ${textRange.font.underline}`);
+
+ console.log("Paragraph format properties of selected text range:");
+ console.log(`\tbulletFormat.visible: ${textRange.paragraphFormat.bulletFormat.visible}`);
+ console.log(`\thorizontalAlignment: ${textRange.paragraphFormat.horizontalAlignment}`);
+ });
+ }
+
/** Default helper for invoking an action and handling errors. */
async function tryCatch(callback) {
try {
@@ -151,16 +184,20 @@ script:
template:
content: |-
- This sample shows how to get selected text, and how to select specific text.
+ This sample shows how to get selected text, and how to select specific text.
- Try it out
-
-
-
-
-
-
+ Try it out
+ Before choosing the Get selected text range button, add text to a slide and select some text.
+
+
+
+
+
+
+ Output
+
+ Output from choosing the Get selected text range button is displayed in this section.
language: html
style:
diff --git a/snippet-extractor-metadata/powerpoint.xlsx b/snippet-extractor-metadata/powerpoint.xlsx
index a4f793ee..27d2f9db 100644
Binary files a/snippet-extractor-metadata/powerpoint.xlsx and b/snippet-extractor-metadata/powerpoint.xlsx differ
diff --git a/snippet-extractor-output/snippets.yaml b/snippet-extractor-output/snippets.yaml
index eba34b10..91d9201b 100644
--- a/snippet-extractor-output/snippets.yaml
+++ b/snippet-extractor-output/snippets.yaml
@@ -15987,6 +15987,37 @@ PowerPoint.BorderProperties#weight:member:
});
await context.sync();
});
+PowerPoint.BulletFormat:class:
+ - >-
+ // Link to full sample:
+ https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/text/get-set-textrange.yaml
+
+
+ // Gets navigational (complex) properties of the selected text range.
+
+ await PowerPoint.run(async (context) => {
+ const textRange: PowerPoint.TextRange = context.presentation.getSelectedTextRange();
+ textRange.load("font,paragraphFormat/bulletFormat,paragraphFormat/horizontalAlignment");
+ await context.sync();
+
+ console.log("Font properties of selected text range:");
+ console.log(`\tallCaps: ${textRange.font.allCaps}`);
+ console.log(`\tbold: ${textRange.font.bold}`);
+ console.log(`\tcolor: ${textRange.font.color}`);
+ console.log(`\tdoubleStrikethrough: ${textRange.font.doubleStrikethrough}`);
+ console.log(`\titalic: ${textRange.font.italic}`);
+ console.log(`\tname: ${textRange.font.name}`);
+ console.log(`\tsize: ${textRange.font.size}`);
+ console.log(`\tsmallCaps: ${textRange.font.smallCaps}`);
+ console.log(`\tstrikethrough: ${textRange.font.strikethrough}`);
+ console.log(`\tsubscript: ${textRange.font.subscript}`);
+ console.log(`\tsuperscript: ${textRange.font.superscript}`);
+ console.log(`\tunderline: ${textRange.font.underline}`);
+
+ console.log("Paragraph format properties of selected text range:");
+ console.log(`\tbulletFormat.visible: ${textRange.paragraphFormat.bulletFormat.visible}`);
+ console.log(`\thorizontalAlignment: ${textRange.paragraphFormat.horizontalAlignment}`);
+ });
PowerPoint.ConnectorType:enum:
- >-
// Link to full sample:
@@ -16004,13 +16035,12 @@ PowerPoint.ConnectorType:enum:
// For a line, left and top are the coordinates of the start point,
// while height and width are the coordinates of the end point.
- const line: PowerPoint.Shape = shapes.addLine(PowerPoint.ConnectorType.straight,
- {
- left: 400,
- top: 200,
- height: 20,
- width: 150
- });
+ const line: PowerPoint.Shape = shapes.addLine(PowerPoint.ConnectorType.straight, {
+ left: 400,
+ top: 200,
+ height: 20,
+ width: 150,
+ });
line.name = "StraightLine";
await context.sync();
@@ -16402,7 +16432,7 @@ PowerPoint.GeometricShapeType:enum:
left: 100,
top: 100,
height: 150,
- width: 150
+ width: 150,
};
const hexagon: PowerPoint.Shape = shapes.addGeometricShape(PowerPoint.GeometricShapeType.hexagon, shapeOptions);
hexagon.name = "Hexagon";
@@ -16489,6 +16519,37 @@ PowerPoint.InsertSlideOptions:interface:
presentation.insertSlidesFromBase64(chosenFileBase64, insertOptions);
await context.sync();
});
+PowerPoint.ParagraphFormat:class:
+ - >-
+ // Link to full sample:
+ https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/text/get-set-textrange.yaml
+
+
+ // Gets navigational (complex) properties of the selected text range.
+
+ await PowerPoint.run(async (context) => {
+ const textRange: PowerPoint.TextRange = context.presentation.getSelectedTextRange();
+ textRange.load("font,paragraphFormat/bulletFormat,paragraphFormat/horizontalAlignment");
+ await context.sync();
+
+ console.log("Font properties of selected text range:");
+ console.log(`\tallCaps: ${textRange.font.allCaps}`);
+ console.log(`\tbold: ${textRange.font.bold}`);
+ console.log(`\tcolor: ${textRange.font.color}`);
+ console.log(`\tdoubleStrikethrough: ${textRange.font.doubleStrikethrough}`);
+ console.log(`\titalic: ${textRange.font.italic}`);
+ console.log(`\tname: ${textRange.font.name}`);
+ console.log(`\tsize: ${textRange.font.size}`);
+ console.log(`\tsmallCaps: ${textRange.font.smallCaps}`);
+ console.log(`\tstrikethrough: ${textRange.font.strikethrough}`);
+ console.log(`\tsubscript: ${textRange.font.subscript}`);
+ console.log(`\tsuperscript: ${textRange.font.superscript}`);
+ console.log(`\tunderline: ${textRange.font.underline}`);
+
+ console.log("Paragraph format properties of selected text range:");
+ console.log(`\tbulletFormat.visible: ${textRange.paragraphFormat.bulletFormat.visible}`);
+ console.log(`\thorizontalAlignment: ${textRange.paragraphFormat.horizontalAlignment}`);
+ });
PowerPoint.ParagraphHorizontalAlignment:enum:
- >-
// Link to full sample:
@@ -16717,7 +16778,7 @@ PowerPoint.Presentation#getSelectedTextRange:member(1):
txtExplained = txtExplained.replace(/\v/g, "VV");
let finalTable = "";
finalTable +=
- "
| Index | Id |
";
+ "| Index | Id |
";
finalTable += "| Raw | " + textRange.text + " |
";
finalTable += "| Html | " + txtHtml + " |
";
finalTable += "| Exp | " + txtExplained + " |
";
@@ -16725,7 +16786,7 @@ PowerPoint.Presentation#getSelectedTextRange:member(1):
finalTable += "| Length | " + textRange.length + " |
";
finalTable += "
";
const outputSpan = document.getElementById("outputSpan");
- outputSpan.innerHTML = ""
+ outputSpan.innerHTML = "";
outputSpan.innerHTML += finalTable;
});
- >-
@@ -16738,7 +16799,10 @@ PowerPoint.Presentation#getSelectedTextRange:member(1):
await PowerPoint.run(async (context) => {
const slide1: PowerPoint.Slide = context.presentation.slides.getItem(savedTextSlideSelection[0]);
const shape1: PowerPoint.Shape = slide1.shapes.getItem(savedTextShapeSelection[0]);
- const textRange: PowerPoint.TextRange = shape1.textFrame.textRange.getSubstring(savedTextTextRangeStart, savedTextTextRangeLength);
+ const textRange: PowerPoint.TextRange = shape1.textFrame.textRange.getSubstring(
+ savedTextTextRangeStart,
+ savedTextTextRangeLength,
+ );
textRange.setSelected();
await context.sync();
});
@@ -16978,9 +17042,11 @@ PowerPoint.Shape#fill:member:
await PowerPoint.run(async (context) => {
const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes();
const shapeCount = shapes.getCount();
- shapes.load("items");
+ shapes.load("items/fill/type");
await context.sync();
shapes.items.map((shape) => {
+ const shapeFillType = shape.fill.type as PowerPoint.ShapeFillType;
+ console.log(`Shape ID ${shape.id} original fill type: ${shapeFillType}`);
shape.fill.setSolidColor("red");
});
await context.sync();
@@ -17221,13 +17287,44 @@ PowerPoint.ShapeAddOptions:interface:
left: 100,
top: 100,
height: 150,
- width: 150
+ width: 150,
};
const hexagon: PowerPoint.Shape = shapes.addGeometricShape(PowerPoint.GeometricShapeType.hexagon, shapeOptions);
hexagon.name = "Hexagon";
await context.sync();
});
+PowerPoint.ShapeAutoSize:enum:
+ - >-
+ // Link to full sample:
+ https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/shapes.yaml
+
+
+ // This function gets the collection of shapes on the first slide,
+
+ // and adds a brace pair, {}, to the collection, while specifying its
+
+ // location and size. Then it names the shape, sets its text and font
+
+ // color, and centers it inside the braces.
+
+ await PowerPoint.run(async (context) => {
+ const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes;
+ const braces: PowerPoint.Shape = shapes.addGeometricShape(PowerPoint.GeometricShapeType.bracePair, {
+ left: 100,
+ top: 400,
+ height: 50,
+ width: 150,
+ });
+ braces.name = "Braces";
+ braces.textFrame.textRange.text = "Shape text";
+ braces.textFrame.textRange.font.color = "purple";
+ braces.textFrame.textRange.font.underline = PowerPoint.ShapeFontUnderlineStyle.heavy;
+ braces.textFrame.verticalAlignment = PowerPoint.TextVerticalAlignment.middleCentered;
+ braces.textFrame.autoSizeSetting = PowerPoint.ShapeAutoSize.autoSizeShapeToFitText;
+
+ return context.sync();
+ });
PowerPoint.ShapeCollection:class:
- >-
// Link to full sample:
@@ -17268,7 +17365,7 @@ PowerPoint.ShapeCollection#addGeometricShape:member(1):
left: 100,
top: 100,
height: 150,
- width: 150
+ width: 150,
};
const hexagon: PowerPoint.Shape = shapes.addGeometricShape(PowerPoint.GeometricShapeType.hexagon, shapeOptions);
hexagon.name = "Hexagon";
@@ -17322,13 +17419,12 @@ PowerPoint.ShapeCollection#addLine:member(1):
// For a line, left and top are the coordinates of the start point,
// while height and width are the coordinates of the end point.
- const line: PowerPoint.Shape = shapes.addLine(PowerPoint.ConnectorType.straight,
- {
- left: 400,
- top: 200,
- height: 20,
- width: 150
- });
+ const line: PowerPoint.Shape = shapes.addLine(PowerPoint.ConnectorType.straight, {
+ left: 400,
+ top: 200,
+ height: 20,
+ width: 150,
+ });
line.name = "StraightLine";
await context.sync();
@@ -17362,13 +17458,12 @@ PowerPoint.ShapeCollection#addTextBox:member(1):
await PowerPoint.run(async (context) => {
const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes;
- const textbox: PowerPoint.Shape = shapes.addTextBox("Hello!",
- {
- left: 100,
- top: 300,
- height: 300,
- width: 450
- });
+ const textbox: PowerPoint.Shape = shapes.addTextBox("Hello!", {
+ left: 100,
+ top: 300,
+ height: 300,
+ width: 450,
+ });
textbox.name = "Textbox";
return context.sync();
@@ -17517,9 +17612,11 @@ PowerPoint.ShapeFill#setSolidColor:member(1):
await PowerPoint.run(async (context) => {
const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes();
const shapeCount = shapes.getCount();
- shapes.load("items");
+ shapes.load("items/fill/type");
await context.sync();
shapes.items.map((shape) => {
+ const shapeFillType = shape.fill.type as PowerPoint.ShapeFillType;
+ console.log(`Shape ID ${shape.id} original fill type: ${shapeFillType}`);
shape.fill.setSolidColor("red");
});
await context.sync();
@@ -17541,7 +17638,7 @@ PowerPoint.ShapeFill#foregroundColor:member:
const minNewShapeHeight = 50;
for (let i = 0; i < 20; i++) {
const rectangle: PowerPoint.Shape = currentSlide.shapes.addGeometricShape(
- PowerPoint.GeometricShapeType.rectangle
+ PowerPoint.GeometricShapeType.rectangle,
);
rectangle.height = getRandomBetween(minNewShapeWidth, maxNewShapeWidth);
rectangle.width = getRandomBetween(minNewShapeHeight, maxNewShapeHeight);
@@ -17576,18 +17673,76 @@ PowerPoint.ShapeFill#transparency:member:
});
await context.sync();
});
+PowerPoint.ShapeFill#type:member:
+ - >-
+ // 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: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes();
+ const shapeCount = shapes.getCount();
+ shapes.load("items/fill/type");
+ await context.sync();
+ shapes.items.map((shape) => {
+ const shapeFillType = shape.fill.type as PowerPoint.ShapeFillType;
+ console.log(`Shape ID ${shape.id} original fill type: ${shapeFillType}`);
+ shape.fill.setSolidColor("red");
+ });
+ await context.sync();
+ });
+PowerPoint.ShapeFillType:enum:
+ - >-
+ // 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: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes();
+ const shapeCount = shapes.getCount();
+ shapes.load("items/fill/type");
+ await context.sync();
+ shapes.items.map((shape) => {
+ const shapeFillType = shape.fill.type as PowerPoint.ShapeFillType;
+ console.log(`Shape ID ${shape.id} original fill type: ${shapeFillType}`);
+ shape.fill.setSolidColor("red");
+ });
+ await context.sync();
+ });
PowerPoint.ShapeFont:class:
- >-
// Link to full sample:
https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/text/get-set-textrange.yaml
- // Sets the color of the selected text range to green.
+ // Gets navigational (complex) properties of the selected text range.
await PowerPoint.run(async (context) => {
const textRange: PowerPoint.TextRange = context.presentation.getSelectedTextRange();
- textRange.font.color = "green";
- await context.sync();
+ textRange.load("font,paragraphFormat/bulletFormat,paragraphFormat/horizontalAlignment");
+ await context.sync();
+
+ console.log("Font properties of selected text range:");
+ console.log(`\tallCaps: ${textRange.font.allCaps}`);
+ console.log(`\tbold: ${textRange.font.bold}`);
+ console.log(`\tcolor: ${textRange.font.color}`);
+ console.log(`\tdoubleStrikethrough: ${textRange.font.doubleStrikethrough}`);
+ console.log(`\titalic: ${textRange.font.italic}`);
+ console.log(`\tname: ${textRange.font.name}`);
+ console.log(`\tsize: ${textRange.font.size}`);
+ console.log(`\tsmallCaps: ${textRange.font.smallCaps}`);
+ console.log(`\tstrikethrough: ${textRange.font.strikethrough}`);
+ console.log(`\tsubscript: ${textRange.font.subscript}`);
+ console.log(`\tsuperscript: ${textRange.font.superscript}`);
+ console.log(`\tunderline: ${textRange.font.underline}`);
+
+ console.log("Paragraph format properties of selected text range:");
+ console.log(`\tbulletFormat.visible: ${textRange.paragraphFormat.bulletFormat.visible}`);
+ console.log(`\thorizontalAlignment: ${textRange.paragraphFormat.horizontalAlignment}`);
});
PowerPoint.ShapeFont#color:member:
- >-
@@ -17602,6 +17757,68 @@ PowerPoint.ShapeFont#color:member:
textRange.font.color = "green";
await context.sync();
});
+PowerPoint.ShapeFont#underline:member:
+ - >-
+ // Link to full sample:
+ https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/shapes.yaml
+
+
+ // This function gets the collection of shapes on the first slide,
+
+ // and adds a brace pair, {}, to the collection, while specifying its
+
+ // location and size. Then it names the shape, sets its text and font
+
+ // color, and centers it inside the braces.
+
+ await PowerPoint.run(async (context) => {
+ const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes;
+ const braces: PowerPoint.Shape = shapes.addGeometricShape(PowerPoint.GeometricShapeType.bracePair, {
+ left: 100,
+ top: 400,
+ height: 50,
+ width: 150,
+ });
+ braces.name = "Braces";
+ braces.textFrame.textRange.text = "Shape text";
+ braces.textFrame.textRange.font.color = "purple";
+ braces.textFrame.textRange.font.underline = PowerPoint.ShapeFontUnderlineStyle.heavy;
+ braces.textFrame.verticalAlignment = PowerPoint.TextVerticalAlignment.middleCentered;
+ braces.textFrame.autoSizeSetting = PowerPoint.ShapeAutoSize.autoSizeShapeToFitText;
+
+ return context.sync();
+ });
+PowerPoint.ShapeFontUnderlineStyle:enum:
+ - >-
+ // Link to full sample:
+ https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/shapes.yaml
+
+
+ // This function gets the collection of shapes on the first slide,
+
+ // and adds a brace pair, {}, to the collection, while specifying its
+
+ // location and size. Then it names the shape, sets its text and font
+
+ // color, and centers it inside the braces.
+
+ await PowerPoint.run(async (context) => {
+ const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes;
+ const braces: PowerPoint.Shape = shapes.addGeometricShape(PowerPoint.GeometricShapeType.bracePair, {
+ left: 100,
+ top: 400,
+ height: 50,
+ width: 150,
+ });
+ braces.name = "Braces";
+ braces.textFrame.textRange.text = "Shape text";
+ braces.textFrame.textRange.font.color = "purple";
+ braces.textFrame.textRange.font.underline = PowerPoint.ShapeFontUnderlineStyle.heavy;
+ braces.textFrame.verticalAlignment = PowerPoint.TextVerticalAlignment.middleCentered;
+ braces.textFrame.autoSizeSetting = PowerPoint.ShapeAutoSize.autoSizeShapeToFitText;
+
+ return context.sync();
+ });
PowerPoint.ShapeGroup:class:
- >-
// Link to full sample:
@@ -17742,9 +17959,11 @@ PowerPoint.ShapeScopedCollection:class:
await PowerPoint.run(async (context) => {
const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes();
const shapeCount = shapes.getCount();
- shapes.load("items");
+ shapes.load("items/fill/type");
await context.sync();
shapes.items.map((shape) => {
+ const shapeFillType = shape.fill.type as PowerPoint.ShapeFillType;
+ console.log(`Shape ID ${shape.id} original fill type: ${shapeFillType}`);
shape.fill.setSolidColor("red");
});
await context.sync();
@@ -17971,7 +18190,7 @@ PowerPoint.Slide#setSelectedShapes:member(1):
shape2.load("id");
await context.sync();
- console.log(`IDs: ${shape1.id}, ${shape2.id}`)
+ console.log(`IDs: ${shape1.id}, ${shape2.id}`);
slide1.setSelectedShapes([shape1.id, shape2.id]);
await context.sync();
});
@@ -19354,20 +19573,38 @@ PowerPoint.TextFrame:class:
textRange10.setSelected();
await context.sync();
});
-PowerPoint.TextRange:class:
+PowerPoint.TextFrame#autoSizeSetting:member:
- >-
// Link to full sample:
- https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/text/get-set-textrange.yaml
+ https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/shapes.yaml
- // Sets the color of the selected text range to green.
+ // This function gets the collection of shapes on the first slide,
+
+ // and adds a brace pair, {}, to the collection, while specifying its
+
+ // location and size. Then it names the shape, sets its text and font
+
+ // color, and centers it inside the braces.
await PowerPoint.run(async (context) => {
- const textRange: PowerPoint.TextRange = context.presentation.getSelectedTextRange();
- textRange.font.color = "green";
- await context.sync();
+ const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes;
+ const braces: PowerPoint.Shape = shapes.addGeometricShape(PowerPoint.GeometricShapeType.bracePair, {
+ left: 100,
+ top: 400,
+ height: 50,
+ width: 150,
+ });
+ braces.name = "Braces";
+ braces.textFrame.textRange.text = "Shape text";
+ braces.textFrame.textRange.font.color = "purple";
+ braces.textFrame.textRange.font.underline = PowerPoint.ShapeFontUnderlineStyle.heavy;
+ braces.textFrame.verticalAlignment = PowerPoint.TextVerticalAlignment.middleCentered;
+ braces.textFrame.autoSizeSetting = PowerPoint.ShapeAutoSize.autoSizeShapeToFitText;
+
+ return context.sync();
});
-PowerPoint.TextRange#font:member:
+PowerPoint.TextRange:class:
- >-
// Link to full sample:
https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/text/get-set-textrange.yaml
@@ -19424,10 +19661,57 @@ PowerPoint.TextRange#setSelected:member(1):
await PowerPoint.run(async (context) => {
const slide1: PowerPoint.Slide = context.presentation.slides.getItem(savedTextSlideSelection[0]);
const shape1: PowerPoint.Shape = slide1.shapes.getItem(savedTextShapeSelection[0]);
- const textRange: PowerPoint.TextRange = shape1.textFrame.textRange.getSubstring(savedTextTextRangeStart, savedTextTextRangeLength);
+ const textRange: PowerPoint.TextRange = shape1.textFrame.textRange.getSubstring(
+ savedTextTextRangeStart,
+ savedTextTextRangeLength,
+ );
textRange.setSelected();
await context.sync();
});
+PowerPoint.TextRange#font:member:
+ - >-
+ // Link to full sample:
+ https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/text/get-set-textrange.yaml
+
+
+ // Sets the color of the selected text range to green.
+
+ await PowerPoint.run(async (context) => {
+ const textRange: PowerPoint.TextRange = context.presentation.getSelectedTextRange();
+ textRange.font.color = "green";
+ await context.sync();
+ });
+PowerPoint.TextRange#paragraphFormat:member:
+ - >-
+ // Link to full sample:
+ https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/text/get-set-textrange.yaml
+
+
+ // Gets navigational (complex) properties of the selected text range.
+
+ await PowerPoint.run(async (context) => {
+ const textRange: PowerPoint.TextRange = context.presentation.getSelectedTextRange();
+ textRange.load("font,paragraphFormat/bulletFormat,paragraphFormat/horizontalAlignment");
+ await context.sync();
+
+ console.log("Font properties of selected text range:");
+ console.log(`\tallCaps: ${textRange.font.allCaps}`);
+ console.log(`\tbold: ${textRange.font.bold}`);
+ console.log(`\tcolor: ${textRange.font.color}`);
+ console.log(`\tdoubleStrikethrough: ${textRange.font.doubleStrikethrough}`);
+ console.log(`\titalic: ${textRange.font.italic}`);
+ console.log(`\tname: ${textRange.font.name}`);
+ console.log(`\tsize: ${textRange.font.size}`);
+ console.log(`\tsmallCaps: ${textRange.font.smallCaps}`);
+ console.log(`\tstrikethrough: ${textRange.font.strikethrough}`);
+ console.log(`\tsubscript: ${textRange.font.subscript}`);
+ console.log(`\tsuperscript: ${textRange.font.superscript}`);
+ console.log(`\tunderline: ${textRange.font.underline}`);
+
+ console.log("Paragraph format properties of selected text range:");
+ console.log(`\tbulletFormat.visible: ${textRange.paragraphFormat.bulletFormat.visible}`);
+ console.log(`\thorizontalAlignment: ${textRange.paragraphFormat.horizontalAlignment}`);
+ });
PowerPoint.TextRun:interface:
- >-
// Link to full sample:
@@ -19494,15 +19778,17 @@ PowerPoint.TextVerticalAlignment:enum:
await PowerPoint.run(async (context) => {
const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes;
const braces: PowerPoint.Shape = shapes.addGeometricShape(PowerPoint.GeometricShapeType.bracePair, {
- left: 100,
- top: 400,
- height: 50,
- width: 150
- });
+ left: 100,
+ top: 400,
+ height: 50,
+ width: 150,
+ });
braces.name = "Braces";
braces.textFrame.textRange.text = "Shape text";
braces.textFrame.textRange.font.color = "purple";
+ braces.textFrame.textRange.font.underline = PowerPoint.ShapeFontUnderlineStyle.heavy;
braces.textFrame.verticalAlignment = PowerPoint.TextVerticalAlignment.middleCentered;
+ braces.textFrame.autoSizeSetting = PowerPoint.ShapeAutoSize.autoSizeShapeToFitText;
return context.sync();
});