diff --git a/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.connectortype.yml b/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.connectortype.yml index 8a0a750565..7b30df9b51 100644 --- a/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.connectortype.yml +++ b/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.connectortype.yml @@ -24,11 +24,11 @@ remarks: >- // start and end points. Then it names the shape. await PowerPoint.run(async (context) => { - const shapes = context.presentation.slides.getItemAt(0).shapes; + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; // 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 = shapes.addLine(PowerPoint.ConnectorType.straight, + const line: PowerPoint.Shape = shapes.addLine(PowerPoint.ConnectorType.straight, { left: 400, top: 200, diff --git a/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.geometricshapetype.yml b/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.geometricshapetype.yml index b060114f7e..46f2a39913 100644 --- a/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.geometricshapetype.yml +++ b/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.geometricshapetype.yml @@ -24,14 +24,14 @@ remarks: >- // location and size. Then it names the shape. await PowerPoint.run(async (context) => { - const shapes = context.presentation.slides.getItemAt(0).shapes; - const hexagon = shapes.addGeometricShape(PowerPoint.GeometricShapeType.hexagon, - { - left: 100, - top: 100, - height: 150, - width: 150 - }); + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; + const shapeOptions: PowerPoint.ShapeAddOptions = { + left: 100, + top: 100, + height: 150, + width: 150 + }; + const hexagon: PowerPoint.Shape = shapes.addGeometricShape(PowerPoint.GeometricShapeType.hexagon, shapeOptions); hexagon.name = "Hexagon"; await context.sync(); diff --git a/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.insertslideformatting.yml b/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.insertslideformatting.yml index c23c7dca4d..e19936d98e 100644 --- a/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.insertslideformatting.yml +++ b/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.insertslideformatting.yml @@ -19,8 +19,8 @@ remarks: >- await PowerPoint.run(async function(context) { // Get the ID of the first selected slide. - const presentation = context.presentation; - const selected = presentation.getSelectedSlides().getItemAt(0); + const presentation: PowerPoint.Presentation = context.presentation; + const selected: PowerPoint.Slide = presentation.getSelectedSlides().getItemAt(0); selected.load("id"); await context.sync(); diff --git a/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.insertslideoptions.yml b/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.insertslideoptions.yml index 1f359cec9d..ea50dfea43 100644 --- a/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.insertslideoptions.yml +++ b/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.insertslideoptions.yml @@ -19,8 +19,8 @@ remarks: >- await PowerPoint.run(async function(context) { // Get the ID of the first selected slide. - const presentation = context.presentation; - const selected = presentation.getSelectedSlides().getItemAt(0); + const presentation: PowerPoint.Presentation = context.presentation; + const selected: PowerPoint.Slide = presentation.getSelectedSlides().getItemAt(0); selected.load("id"); await context.sync(); diff --git a/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.presentation.yml b/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.presentation.yml index 83ccdbc1a4..a1f4003b81 100644 --- a/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.presentation.yml +++ b/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.presentation.yml @@ -19,8 +19,8 @@ remarks: >- await PowerPoint.run(async function(context) { // Get the ID of the first selected slide. - const presentation = context.presentation; - const selected = presentation.getSelectedSlides().getItemAt(0); + const presentation: PowerPoint.Presentation = context.presentation; + const selected: PowerPoint.Slide = presentation.getSelectedSlides().getItemAt(0); selected.load("id"); await context.sync(); @@ -150,7 +150,7 @@ methods: // Arranges the selected shapes in a line from left to right. await PowerPoint.run(async (context) => { - const shapes = context.presentation.getSelectedShapes(); + const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes(); const shapeCount = shapes.getCount(); shapes.load("items"); await context.sync(); @@ -178,7 +178,7 @@ methods: await PowerPoint.run(async (context) => { let finalTable = ""; - const shapes = context.presentation.getSelectedShapes(); + const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes(); const shapeCount = shapes.getCount(); await context.sync(); finalTable += "
getSelectedShapes.getCount returned:" + shapeCount.value + "
"; @@ -203,7 +203,7 @@ methods: await PowerPoint.run(async (context) => { context.presentation.load("slides"); await context.sync(); - const slides = context.presentation.getSelectedSlides(); + const slides: PowerPoint.SlideScopedCollection = context.presentation.getSelectedSlides(); const slideCount = slides.getCount(); slides.load("items"); await context.sync(); @@ -211,7 +211,7 @@ methods: slides.items.map((slide) => { savedSlideSelection.push(slide.id); }); - const shapes = context.presentation.getSelectedShapes(); + const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes(); const shapeCount = shapes.getCount(); shapes.load("items"); await context.sync(); @@ -258,7 +258,7 @@ methods: const allSlidesCount = context.presentation.slides.getCount(); context.presentation.slides.load("items"); await context.sync(); - let allSlideItems = context.presentation.slides.items; + let allSlideItems: PowerPoint.Slide[] = context.presentation.slides.items; allSlideItems.map((slide, index) => { allSlidesList[slide.id] = `Slide ${index + 1}`; }); @@ -266,7 +266,7 @@ methods: if ($("#id-check-usenative").is(":checked")) { context.presentation.load("tags"); } - const slides = context.presentation.getSelectedSlides(); + const slides: PowerPoint.SlideScopedCollection = context.presentation.getSelectedSlides(); const slideCount = slides.getCount(); slides.load("items"); await context.sync(); @@ -291,7 +291,7 @@ methods: let finalTable = ""; context.presentation.load("slides"); await context.sync(); - const slides = context.presentation.getSelectedSlides(); + const slides: PowerPoint.SlideScopedCollection = context.presentation.getSelectedSlides(); const slideCount = slides.getCount(); await context.sync(); finalTable += "
getSelectedSlides.getCount returned:" + slideCount.value + "
"; @@ -340,7 +340,7 @@ methods: // Gets the selected text range and prints data about the range on the task pane. await PowerPoint.run(async (context) => { - const textRange = context.presentation.getSelectedTextRange(); + const textRange: PowerPoint.TextRange = context.presentation.getSelectedTextRange(); try { await context.sync(); } catch (error) { @@ -379,9 +379,9 @@ methods: // Sets the range selection to the range that was saved previously. await PowerPoint.run(async (context) => { - const slide1 = context.presentation.slides.getItem(savedTextSlideSelection[0]); - const shape1 = slide1.shapes.getItem(savedTextShapeSelection[0]); - const textRange = shape1.textFrame.textRange.getSubstring(savedTextTextRangeStart, savedTextTextRangeLength); + 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); textRange.setSelected(); await context.sync(); }); @@ -429,8 +429,8 @@ methods: await PowerPoint.run(async function(context) { // Get the ID of the first selected slide. - const presentation = context.presentation; - const selected = presentation.getSelectedSlides().getItemAt(0); + const presentation: PowerPoint.Presentation = context.presentation; + const selected: PowerPoint.Slide = presentation.getSelectedSlides().getItemAt(0); selected.load("id"); await context.sync(); @@ -563,9 +563,9 @@ methods: await PowerPoint.run(async (context) => { context.presentation.load("slides"); await context.sync(); - const slide2 = context.presentation.slides.getItemAt(1); - const slide4 = context.presentation.slides.getItemAt(3); - const slide5 = context.presentation.slides.getItemAt(4); + const slide2: PowerPoint.Slide = context.presentation.slides.getItemAt(1); + const slide4: PowerPoint.Slide = context.presentation.slides.getItemAt(3); + const slide5: PowerPoint.Slide = context.presentation.slides.getItemAt(4); slide2.load("id"); slide4.load("id"); slide5.load("id"); diff --git a/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.shape.yml b/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.shape.yml index 68cb84d735..d93e171942 100644 --- a/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.shape.yml +++ b/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.shape.yml @@ -21,7 +21,7 @@ remarks: >- await PowerPoint.run(async (context) => { // Get the type of shape for every shape in the collection. - const shapes = context.presentation.slides.getItemAt(0).shapes; + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; shapes.load("type"); await context.sync(); @@ -88,7 +88,7 @@ properties: // Changes the selected shapes fill color to red. await PowerPoint.run(async (context) => { - const shapes = context.presentation.getSelectedShapes(); + const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes(); const shapeCount = shapes.getCount(); shapes.load("items"); await context.sync(); @@ -128,7 +128,7 @@ properties: // Arranges the selected shapes in a line from left to right. await PowerPoint.run(async (context) => { - const shapes = context.presentation.getSelectedShapes(); + const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes(); const shapeCount = shapes.getCount(); shapes.load("items"); await context.sync(); @@ -188,7 +188,7 @@ properties: // Arranges the selected shapes in a line from left to right. await PowerPoint.run(async (context) => { - const shapes = context.presentation.getSelectedShapes(); + const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes(); const shapeCount = shapes.getCount(); shapes.load("items"); await context.sync(); @@ -284,7 +284,7 @@ properties: // Arranges the selected shapes in a line from left to right. await PowerPoint.run(async (context) => { - const shapes = context.presentation.getSelectedShapes(); + const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes(); const shapeCount = shapes.getCount(); shapes.load("items"); await context.sync(); @@ -333,7 +333,7 @@ properties: await PowerPoint.run(async (context) => { // Get the type of shape for every shape in the collection. - const shapes = context.presentation.slides.getItemAt(0).shapes; + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; shapes.load("type"); await context.sync(); @@ -378,7 +378,7 @@ properties: // Arranges the selected shapes in a line from left to right. await PowerPoint.run(async (context) => { - const shapes = context.presentation.getSelectedShapes(); + const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes(); const shapeCount = shapes.getCount(); shapes.load("items"); await context.sync(); @@ -411,7 +411,38 @@ methods: package: powerpoint! fullName: delete() summary: Deletes the shape from the shape collection. Does nothing if the shape does not exist. - remarks: '\[ [API set: PowerPointApi 1.3](/javascript/api/requirement-sets/powerpoint/powerpoint-api-requirement-sets) \]' + remarks: >- + \[ [API set: PowerPointApi 1.3](/javascript/api/requirement-sets/powerpoint/powerpoint-api-requirement-sets) \] + + + #### Examples + + + ```TypeScript + + // 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 then iterates through them, deleting each one. + + await PowerPoint.run(async (context) => { + const slide: PowerPoint.Slide = context.presentation.slides.getItemAt(0); + const shapes: PowerPoint.ShapeCollection = slide.shapes; + + // Load all the shapes in the collection without loading their properties. + shapes.load("items/$none"); + + await context.sync(); + + shapes.items.forEach((shape) => shape.delete()); + + await context.sync(); + }); + + ``` isPreview: false isDeprecated: false syntax: diff --git a/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.shapeaddoptions.yml b/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.shapeaddoptions.yml index 241f97b00f..d492e51cf7 100644 --- a/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.shapeaddoptions.yml +++ b/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.shapeaddoptions.yml @@ -4,7 +4,40 @@ uid: 'powerpoint!PowerPoint.ShapeAddOptions:interface' package: powerpoint! fullName: PowerPoint.ShapeAddOptions summary: Represents the available options when adding shapes. -remarks: '\[ [API set: PowerPointApi 1.4](/javascript/api/requirement-sets/powerpoint/powerpoint-api-requirement-sets) \]' +remarks: >- + \[ [API set: PowerPointApi 1.4](/javascript/api/requirement-sets/powerpoint/powerpoint-api-requirement-sets) \] + + + #### Examples + + + ```TypeScript + + // 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 hexagon shape to the collection, while specifying its + + // location and size. Then it names the shape. + + await PowerPoint.run(async (context) => { + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; + const shapeOptions: PowerPoint.ShapeAddOptions = { + left: 100, + top: 100, + height: 150, + width: 150 + }; + const hexagon: PowerPoint.Shape = shapes.addGeometricShape(PowerPoint.GeometricShapeType.hexagon, shapeOptions); + hexagon.name = "Hexagon"; + + await context.sync(); + }); + + ``` isPreview: false isDeprecated: false type: interface diff --git a/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.shapecollection.yml b/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.shapecollection.yml index 8931536b96..a5efe8e5ec 100644 --- a/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.shapecollection.yml +++ b/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.shapecollection.yml @@ -21,7 +21,7 @@ remarks: >- await PowerPoint.run(async (context) => { // Get the type of shape for every shape in the collection. - const shapes = context.presentation.slides.getItemAt(0).shapes; + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; shapes.load("type"); await context.sync(); @@ -91,14 +91,14 @@ methods: // location and size. Then it names the shape. await PowerPoint.run(async (context) => { - const shapes = context.presentation.slides.getItemAt(0).shapes; - const hexagon = shapes.addGeometricShape(PowerPoint.GeometricShapeType.hexagon, - { - left: 100, - top: 100, - height: 150, - width: 150 - }); + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; + const shapeOptions: PowerPoint.ShapeAddOptions = { + left: 100, + top: 100, + height: 150, + width: 150 + }; + const hexagon: PowerPoint.Shape = shapes.addGeometricShape(PowerPoint.GeometricShapeType.hexagon, shapeOptions); hexagon.name = "Hexagon"; await context.sync(); @@ -232,11 +232,11 @@ methods: // start and end points. Then it names the shape. await PowerPoint.run(async (context) => { - const shapes = context.presentation.slides.getItemAt(0).shapes; + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; // 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 = shapes.addLine(PowerPoint.ConnectorType.straight, + const line: PowerPoint.Shape = shapes.addLine(PowerPoint.ConnectorType.straight, { left: 400, top: 200, @@ -320,8 +320,8 @@ methods: // location, and size. Then it names the text box. await PowerPoint.run(async (context) => { - const shapes = context.presentation.slides.getItemAt(0).shapes; - const textbox = shapes.addTextBox("Hello!", + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; + const textbox: PowerPoint.Shape = shapes.addTextBox("Hello!", { left: 100, top: 300, @@ -397,13 +397,13 @@ methods: await PowerPoint.run(async function(context) { - const slide = context.presentation.slides.getItemAt(0); - const shape = slide.shapes.getItemAt(0); + const slide: PowerPoint.Slide = context.presentation.slides.getItemAt(0); + const shape: PowerPoint.Shape = slide.shapes.getItemAt(0); shape.tags.add("MOUNTAIN", "Denali"); await context.sync(); - const myShapeTag = shape.tags.getItem("MOUNTAIN"); + const myShapeTag: PowerPoint.Tag = shape.tags.getItem("MOUNTAIN"); myShapeTag.load("key, value"); await context.sync(); @@ -501,7 +501,7 @@ methods: await PowerPoint.run(async (context) => { // Get the type of shape for every shape in the collection. - const shapes = context.presentation.slides.getItemAt(0).shapes; + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; shapes.load("type"); await context.sync(); diff --git a/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.shapefill.yml b/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.shapefill.yml index bf9d6a34aa..923dd0585d 100644 --- a/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.shapefill.yml +++ b/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.shapefill.yml @@ -21,7 +21,7 @@ remarks: >- await PowerPoint.run(async (context) => { // Get the type of shape for every shape in the collection. - const shapes = context.presentation.slides.getItemAt(0).shapes; + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; shapes.load("type"); await context.sync(); @@ -60,7 +60,42 @@ properties: summary: >- 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"). - remarks: '\[ [API set: PowerPointApi 1.4](/javascript/api/requirement-sets/powerpoint/powerpoint-api-requirement-sets) \]' + remarks: >- + \[ [API set: PowerPointApi 1.4](/javascript/api/requirement-sets/powerpoint/powerpoint-api-requirement-sets) \] + + + #### Examples + + + ```TypeScript + + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/get-set-shapes.yaml + + + // Creates random shapes on the selected slide. + + await PowerPoint.run(async (context) => { + let finalTable = ""; + const currentSlide: PowerPoint.Slide = context.presentation.getSelectedSlides().getItemAt(0); + const maxNewShapeWidth = 200; + const maxNewShapeHeight = 200; + const minNewShapeWidth = 50; + const minNewShapeHeight = 50; + for (let i = 0; i < 20; i++) { + const rectangle: PowerPoint.Shape = currentSlide.shapes.addGeometricShape(PowerPoint.GeometricShapeType.rectangle); + rectangle.height = getRandomBetween(minNewShapeWidth, maxNewShapeWidth); + rectangle.width = getRandomBetween(minNewShapeHeight, maxNewShapeHeight); + rectangle.left = getRandomBetween(0, slideWidth - rectangle.width); + rectangle.top = getRandomBetween(0, slideHeight - rectangle.height); + rectangle.fill.foregroundColor = generateRandomHexColor(); + } + finalTable += "Done
"; + $("#slide-tags").empty(); + $("#slide-tags").append(finalTable); + }); + + ``` isPreview: false isDeprecated: false syntax: @@ -92,7 +127,7 @@ properties: await PowerPoint.run(async (context) => { // Get the type of shape for every shape in the collection. - const shapes = context.presentation.slides.getItemAt(0).shapes; + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; shapes.load("type"); await context.sync(); @@ -232,7 +267,7 @@ methods: // Changes the selected shapes fill color to red. await PowerPoint.run(async (context) => { - const shapes = context.presentation.getSelectedShapes(); + const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes(); const shapeCount = shapes.getCount(); shapes.load("items"); await context.sync(); diff --git a/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.shapefont.yml b/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.shapefont.yml index f74d0f3e9a..1445929e14 100644 --- a/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.shapefont.yml +++ b/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.shapefont.yml @@ -20,7 +20,7 @@ remarks: >- // Sets the color of the selected text range to green. await PowerPoint.run(async (context) => { - const textRange = context.presentation.getSelectedTextRange(); + const textRange: PowerPoint.TextRange = context.presentation.getSelectedTextRange(); textRange.font.color = "green"; await context.sync(); }); @@ -67,7 +67,7 @@ properties: // Sets the color of the selected text range to green. await PowerPoint.run(async (context) => { - const textRange = context.presentation.getSelectedTextRange(); + const textRange: PowerPoint.TextRange = context.presentation.getSelectedTextRange(); textRange.font.color = "green"; await context.sync(); }); diff --git a/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.shapelinedashstyle.yml b/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.shapelinedashstyle.yml index 7d6be56a1f..d45033c2f5 100644 --- a/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.shapelinedashstyle.yml +++ b/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.shapelinedashstyle.yml @@ -21,7 +21,7 @@ remarks: >- await PowerPoint.run(async (context) => { // Get the type of shape for every shape in the collection. - const shapes = context.presentation.slides.getItemAt(0).shapes; + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; shapes.load("type"); await context.sync(); diff --git a/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.shapelineformat.yml b/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.shapelineformat.yml index 813e163050..1c689d7ca6 100644 --- a/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.shapelineformat.yml +++ b/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.shapelineformat.yml @@ -23,7 +23,7 @@ remarks: >- await PowerPoint.run(async (context) => { // Get the type of shape for every shape in the collection. - const shapes = context.presentation.slides.getItemAt(0).shapes; + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; shapes.load("type"); await context.sync(); @@ -93,7 +93,7 @@ properties: await PowerPoint.run(async (context) => { // Get the type of shape for every shape in the collection. - const shapes = context.presentation.slides.getItemAt(0).shapes; + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; shapes.load("type"); await context.sync(); diff --git a/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.shapescopedcollection.yml b/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.shapescopedcollection.yml index c32d8f5d3f..e3ac63938e 100644 --- a/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.shapescopedcollection.yml +++ b/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.shapescopedcollection.yml @@ -4,7 +4,33 @@ uid: 'powerpoint!PowerPoint.ShapeScopedCollection:class' package: powerpoint! fullName: PowerPoint.ShapeScopedCollection summary: Represents a collection of shapes. -remarks: '\[ [API set: PowerPointApi 1.5](/javascript/api/requirement-sets/powerpoint/powerpoint-api-requirement-sets) \]' +remarks: >- + \[ [API set: PowerPointApi 1.5](/javascript/api/requirement-sets/powerpoint/powerpoint-api-requirement-sets) \] + + + #### Examples + + + ```TypeScript + + // 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"); + await context.sync(); + shapes.items.map((shape) => { + shape.fill.setSolidColor("red"); + }); + await context.sync(); + }); + + ``` isPreview: false isDeprecated: false type: class @@ -41,7 +67,40 @@ methods: package: powerpoint! fullName: getCount() summary: Gets the number of shapes in the collection. - remarks: '\[ [API set: PowerPointApi 1.5](/javascript/api/requirement-sets/powerpoint/powerpoint-api-requirement-sets) \]' + remarks: >- + \[ [API set: PowerPointApi 1.5](/javascript/api/requirement-sets/powerpoint/powerpoint-api-requirement-sets) \] + + + #### Examples + + + ```TypeScript + + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/get-set-shapes.yaml + + + // Gets the shapes you selected on the slide and displays their IDs on the task pane. + + await PowerPoint.run(async (context) => { + let finalTable = ""; + const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes(); + const shapeCount = shapes.getCount(); + await context.sync(); + finalTable += "
getSelectedShapes.getCount returned:" + shapeCount.value + "
"; + finalTable += + "
"; + shapes.load("items"); + await context.sync(); + shapes.items.map((shape, index) => { + finalTable += ""; + }); + finalTable += "
IndexId
" + index + "" + shape.id + "
"; + $("#outputSpan").empty(); + $("#outputSpan").append(finalTable); + }); + + ``` isPreview: false isDeprecated: false syntax: diff --git a/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.shapetype.yml b/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.shapetype.yml index aed58db05c..c594c61330 100644 --- a/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.shapetype.yml +++ b/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.shapetype.yml @@ -21,7 +21,7 @@ remarks: >- await PowerPoint.run(async (context) => { // Get the type of shape for every shape in the collection. - const shapes = context.presentation.slides.getItemAt(0).shapes; + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; shapes.load("type"); await context.sync(); diff --git a/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.slide.yml b/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.slide.yml index 3422368489..2e72306b54 100644 --- a/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.slide.yml +++ b/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.slide.yml @@ -20,7 +20,7 @@ remarks: >- // Reselects shapes that were saved previously. await PowerPoint.run(async (context) => { - const slide1 = context.presentation.slides.getItem(savedSlideSelection[0]); + const slide1: PowerPoint.Slide = context.presentation.slides.getItem(savedSlideSelection[0]); await context.sync(); slide1.setSelectedShapes(savedShapeSelection); await context.sync(); @@ -157,7 +157,7 @@ methods: await PowerPoint.run(async (context) => { context.presentation.load("slides"); await context.sync(); - const slides = context.presentation.getSelectedSlides(); + const slides: PowerPoint.SlideScopedCollection = context.presentation.getSelectedSlides(); const slideCount = slides.getCount(); slides.load("items"); await context.sync(); @@ -299,7 +299,7 @@ methods: // Reselects shapes that were saved previously. await PowerPoint.run(async (context) => { - const slide1 = context.presentation.slides.getItem(savedSlideSelection[0]); + const slide1: PowerPoint.Slide = context.presentation.slides.getItem(savedSlideSelection[0]); await context.sync(); slide1.setSelectedShapes(savedShapeSelection); await context.sync(); @@ -317,9 +317,9 @@ methods: const slide1 = context.presentation.slides.getItemAt(0); slide1.load("shapes"); await context.sync(); - const shapes = slide1.shapes; - const shape1 = shapes.getItemAt(0); - const shape2 = shapes.getItemAt(1); + const shapes: PowerPoint.ShapeCollection = slide1.shapes; + const shape1: PowerPoint.Shape = shapes.getItemAt(0); + const shape2: PowerPoint.Shape = shapes.getItemAt(1); shape1.load("id"); shape2.load("id"); await context.sync(); diff --git a/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.slidecollection.yml b/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.slidecollection.yml index a59d072763..5b5589f95c 100644 --- a/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.slidecollection.yml +++ b/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.slidecollection.yml @@ -164,9 +164,9 @@ methods: await PowerPoint.run(async (context) => { context.presentation.load("slides"); await context.sync(); - const slide2 = context.presentation.slides.getItemAt(1); - const slide4 = context.presentation.slides.getItemAt(3); - const slide5 = context.presentation.slides.getItemAt(4); + const slide2: PowerPoint.Slide = context.presentation.slides.getItemAt(1); + const slide4: PowerPoint.Slide = context.presentation.slides.getItemAt(3); + const slide5: PowerPoint.Slide = context.presentation.slides.getItemAt(4); slide2.load("id"); slide4.load("id"); slide5.load("id"); diff --git a/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.slidelayout.yml b/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.slidelayout.yml index e8ec7fff34..785191a11b 100644 --- a/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.slidelayout.yml +++ b/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.slidelayout.yml @@ -19,7 +19,7 @@ remarks: >- await PowerPoint.run(async function(context) { // Load information about all the slide masters and associated layouts. - const slideMasters = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); + const slideMasters: PowerPoint.SlideMasterCollection = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); await context.sync(); // Log the name and ID of each slide master. @@ -28,7 +28,7 @@ remarks: >- console.log("Master ID: " + slideMasters.items[i].id); // Log the name and ID of each slide layout in the slide master. - const layoutsInMaster = slideMasters.items[i].layouts; + const layoutsInMaster: PowerPoint.SlideLayoutCollection = slideMasters.items[i].layouts; for (let j = 0; j < layoutsInMaster.items.length; j++) { console.log(" Layout name: " + layoutsInMaster.items[j].name + " Layout ID: " + layoutsInMaster.items[j].id); } @@ -88,7 +88,7 @@ properties: await PowerPoint.run(async function(context) { // Load information about all the slide masters and associated layouts. - const slideMasters = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); + const slideMasters: PowerPoint.SlideMasterCollection = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); await context.sync(); // Log the name and ID of each slide master. @@ -97,7 +97,7 @@ properties: console.log("Master ID: " + slideMasters.items[i].id); // Log the name and ID of each slide layout in the slide master. - const layoutsInMaster = slideMasters.items[i].layouts; + const layoutsInMaster: PowerPoint.SlideLayoutCollection = slideMasters.items[i].layouts; for (let j = 0; j < layoutsInMaster.items.length; j++) { console.log(" Layout name: " + layoutsInMaster.items[j].name + " Layout ID: " + layoutsInMaster.items[j].id); } diff --git a/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.slidelayoutcollection.yml b/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.slidelayoutcollection.yml index b67d17fba0..7076f35327 100644 --- a/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.slidelayoutcollection.yml +++ b/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.slidelayoutcollection.yml @@ -19,7 +19,7 @@ remarks: >- await PowerPoint.run(async function(context) { // Load information about all the slide masters and associated layouts. - const slideMasters = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); + const slideMasters: PowerPoint.SlideMasterCollection = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); await context.sync(); // Log the name and ID of each slide master. @@ -28,7 +28,7 @@ remarks: >- console.log("Master ID: " + slideMasters.items[i].id); // Log the name and ID of each slide layout in the slide master. - const layoutsInMaster = slideMasters.items[i].layouts; + const layoutsInMaster: PowerPoint.SlideLayoutCollection = slideMasters.items[i].layouts; for (let j = 0; j < layoutsInMaster.items.length; j++) { console.log(" Layout name: " + layoutsInMaster.items[j].name + " Layout ID: " + layoutsInMaster.items[j].id); } @@ -190,7 +190,7 @@ methods: await PowerPoint.run(async function(context) { // Load information about all the slide masters and associated layouts. - const slideMasters = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); + const slideMasters: PowerPoint.SlideMasterCollection = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); await context.sync(); // Log the name and ID of each slide master. @@ -199,7 +199,7 @@ methods: console.log("Master ID: " + slideMasters.items[i].id); // Log the name and ID of each slide layout in the slide master. - const layoutsInMaster = slideMasters.items[i].layouts; + const layoutsInMaster: PowerPoint.SlideLayoutCollection = slideMasters.items[i].layouts; for (let j = 0; j < layoutsInMaster.items.length; j++) { console.log(" Layout name: " + layoutsInMaster.items[j].name + " Layout ID: " + layoutsInMaster.items[j].id); } diff --git a/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.slidemaster.yml b/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.slidemaster.yml index 289169800a..fcdec8e0f9 100644 --- a/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.slidemaster.yml +++ b/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.slidemaster.yml @@ -19,7 +19,7 @@ remarks: >- await PowerPoint.run(async function(context) { // Load information about all the slide masters and associated layouts. - const slideMasters = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); + const slideMasters: PowerPoint.SlideMasterCollection = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); await context.sync(); // Log the name and ID of each slide master. @@ -28,7 +28,7 @@ remarks: >- console.log("Master ID: " + slideMasters.items[i].id); // Log the name and ID of each slide layout in the slide master. - const layoutsInMaster = slideMasters.items[i].layouts; + const layoutsInMaster: PowerPoint.SlideLayoutCollection = slideMasters.items[i].layouts; for (let j = 0; j < layoutsInMaster.items.length; j++) { console.log(" Layout name: " + layoutsInMaster.items[j].name + " Layout ID: " + layoutsInMaster.items[j].id); } @@ -88,7 +88,7 @@ properties: await PowerPoint.run(async function(context) { // Load information about all the slide masters and associated layouts. - const slideMasters = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); + const slideMasters: PowerPoint.SlideMasterCollection = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); await context.sync(); // Log the name and ID of each slide master. @@ -97,7 +97,7 @@ properties: console.log("Master ID: " + slideMasters.items[i].id); // Log the name and ID of each slide layout in the slide master. - const layoutsInMaster = slideMasters.items[i].layouts; + const layoutsInMaster: PowerPoint.SlideLayoutCollection = slideMasters.items[i].layouts; for (let j = 0; j < layoutsInMaster.items.length; j++) { console.log(" Layout name: " + layoutsInMaster.items[j].name + " Layout ID: " + layoutsInMaster.items[j].id); } diff --git a/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.slidemastercollection.yml b/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.slidemastercollection.yml index 8f3aef0c34..f3022d8d5b 100644 --- a/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.slidemastercollection.yml +++ b/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.slidemastercollection.yml @@ -19,7 +19,7 @@ remarks: >- await PowerPoint.run(async function(context) { // Load information about all the slide masters and associated layouts. - const slideMasters = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); + const slideMasters: PowerPoint.SlideMasterCollection = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); await context.sync(); // Log the name and ID of each slide master. @@ -28,7 +28,7 @@ remarks: >- console.log("Master ID: " + slideMasters.items[i].id); // Log the name and ID of each slide layout in the slide master. - const layoutsInMaster = slideMasters.items[i].layouts; + const layoutsInMaster: PowerPoint.SlideLayoutCollection = slideMasters.items[i].layouts; for (let j = 0; j < layoutsInMaster.items.length; j++) { console.log(" Layout name: " + layoutsInMaster.items[j].name + " Layout ID: " + layoutsInMaster.items[j].id); } @@ -190,7 +190,7 @@ methods: await PowerPoint.run(async function(context) { // Load information about all the slide masters and associated layouts. - const slideMasters = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); + const slideMasters: PowerPoint.SlideMasterCollection = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); await context.sync(); // Log the name and ID of each slide master. @@ -199,7 +199,7 @@ methods: console.log("Master ID: " + slideMasters.items[i].id); // Log the name and ID of each slide layout in the slide master. - const layoutsInMaster = slideMasters.items[i].layouts; + const layoutsInMaster: PowerPoint.SlideLayoutCollection = slideMasters.items[i].layouts; for (let j = 0; j < layoutsInMaster.items.length; j++) { console.log(" Layout name: " + layoutsInMaster.items[j].name + " Layout ID: " + layoutsInMaster.items[j].id); } diff --git a/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.slidescopedcollection.yml b/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.slidescopedcollection.yml index 9215cb0ed3..a4f4400712 100644 --- a/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.slidescopedcollection.yml +++ b/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.slidescopedcollection.yml @@ -4,7 +4,42 @@ uid: 'powerpoint!PowerPoint.SlideScopedCollection:class' package: powerpoint! fullName: PowerPoint.SlideScopedCollection summary: Represents a collection of slides in the presentation. -remarks: '\[ [API set: PowerPointApi 1.5](/javascript/api/requirement-sets/powerpoint/powerpoint-api-requirement-sets) \]' +remarks: >- + \[ [API set: PowerPointApi 1.5](/javascript/api/requirement-sets/powerpoint/powerpoint-api-requirement-sets) \] + + + #### Examples + + + ```TypeScript + + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/get-set-shapes.yaml + + + // Saves which shapes are selected so that they can be reselected later. + + await PowerPoint.run(async (context) => { + context.presentation.load("slides"); + await context.sync(); + const slides: PowerPoint.SlideScopedCollection = context.presentation.getSelectedSlides(); + const slideCount = slides.getCount(); + slides.load("items"); + await context.sync(); + savedSlideSelection = []; + slides.items.map((slide) => { + savedSlideSelection.push(slide.id); + }); + const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes(); + const shapeCount = shapes.getCount(); + shapes.load("items"); + await context.sync(); + shapes.items.map((shape) => { + savedShapeSelection.push(shape.id); + }); + }); + + ``` isPreview: false isDeprecated: false type: class diff --git a/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.tag.yml b/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.tag.yml index b1fb1165ab..58489cace5 100644 --- a/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.tag.yml +++ b/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.tag.yml @@ -4,7 +4,34 @@ uid: 'powerpoint!PowerPoint.Tag:class' package: powerpoint! fullName: PowerPoint.Tag summary: Represents a single tag in the slide. -remarks: '\[ [API set: PowerPointApi 1.3](/javascript/api/requirement-sets/powerpoint/powerpoint-api-requirement-sets) \]' +remarks: >- + \[ [API set: PowerPointApi 1.3](/javascript/api/requirement-sets/powerpoint/powerpoint-api-requirement-sets) \] + + + #### Examples + + + ```TypeScript + + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/tags/tags.yaml + + + await PowerPoint.run(async function (context) { + let presentationTags: PowerPoint.TagCollection = context.presentation.tags; + presentationTags.add("COLOR", "blue"); + + await context.sync(); + + const tag: PowerPoint.Tag = presentationTags.getItem("COLOR"); + tag.load("key, value"); + + await context.sync(); + + console.log("Added key " + JSON.stringify(tag.key) + " with value " + JSON.stringify(tag.value)); + }); + + ``` isPreview: false isDeprecated: false type: class diff --git a/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.tagcollection.yml b/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.tagcollection.yml index 81adc1217a..a454993603 100644 --- a/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.tagcollection.yml +++ b/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.tagcollection.yml @@ -23,12 +23,12 @@ remarks: >- // Decrement because the getSelectedSlideByIndex method is 1-based, // but the getItemAt method is 0-based. selectedSlideIndex = selectedSlideIndex - 1; - const slide = context.presentation.slides.getItemAt(selectedSlideIndex); + const slide: PowerPoint.Slide = context.presentation.slides.getItemAt(selectedSlideIndex); slide.tags.add("CUSTOMER_TYPE", "Premium"); await context.sync(); - const audienceTag = slide.tags.getItem("CUSTOMER_TYPE"); + const audienceTag: PowerPoint.Tag = slide.tags.getItem("CUSTOMER_TYPE"); audienceTag.load("key, value"); await context.sync(); @@ -89,7 +89,7 @@ methods: await PowerPoint.run(async function(context) { - const slide = context.presentation.slides.getItemAt(0); + const slide: PowerPoint.Slide = context.presentation.slides.getItemAt(0); slide.tags.add("OCEAN", "Indian"); slide.tags.add("PLANET", "Jupiter"); slide.tags.add("CONTINENT", "Antarctica"); @@ -141,7 +141,7 @@ methods: await PowerPoint.run(async function (context) { - let presentationTags = context.presentation.tags; + let presentationTags: PowerPoint.TagCollection = context.presentation.tags; presentationTags.delete("COLOR"); @@ -201,12 +201,12 @@ methods: // Decrement because the getSelectedSlideByIndex method is 1-based, // but the getItemAt method is 0-based. selectedSlideIndex = selectedSlideIndex - 1; - const slide = context.presentation.slides.getItemAt(selectedSlideIndex); + const slide: PowerPoint.Slide = context.presentation.slides.getItemAt(selectedSlideIndex); slide.tags.add("CUSTOMER_TYPE", "Premium"); await context.sync(); - const audienceTag = slide.tags.getItem("CUSTOMER_TYPE"); + const audienceTag: PowerPoint.Tag = slide.tags.getItem("CUSTOMER_TYPE"); audienceTag.load("key, value"); await context.sync(); diff --git a/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.textframe.yml b/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.textframe.yml index 013eb8fd79..6d2e0188c3 100644 --- a/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.textframe.yml +++ b/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.textframe.yml @@ -4,7 +4,49 @@ uid: 'powerpoint!PowerPoint.TextFrame:class' package: powerpoint! fullName: PowerPoint.TextFrame summary: Represents the text frame of a shape object. -remarks: '\[ [API set: PowerPointApi 1.4](/javascript/api/requirement-sets/powerpoint/powerpoint-api-requirement-sets) \]' +remarks: >- + \[ [API set: PowerPointApi 1.4](/javascript/api/requirement-sets/powerpoint/powerpoint-api-requirement-sets) \] + + + #### Examples + + + ```TypeScript + + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/text/get-set-textrange.yaml + + + // Selects the first 10 characters of the selected shape. + + await PowerPoint.run(async (context) => { + const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes(); + const shapeCount = shapes.getCount(); + await context.sync(); + if (shapeCount.value !== 1) { + console.warn("You must select only one shape with text in it."); + return; + } + const shape: PowerPoint.Shape = shapes.getItemAt(0); + const textFrame: PowerPoint.TextFrame = shape.textFrame.load("textRange,hasText"); + await context.sync(); + if (textFrame.hasText != true) { + console.warn("You must select only one shape with text in it."); + return; + } + const textRange: PowerPoint.TextRange = textFrame.textRange; + textRange.load("text"); + await context.sync(); + if (textRange.text.length < 10) { + console.warn("You must select only one shape with at least 10 characters in it."); + return; + } + const textRange10 = textRange.getSubstring(0, 10); + textRange10.setSelected(); + await context.sync(); + }); + + ``` isPreview: false isDeprecated: false type: class diff --git a/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.textrange.yml b/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.textrange.yml index 819a5bb4d6..4e10393b79 100644 --- a/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.textrange.yml +++ b/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.textrange.yml @@ -20,7 +20,7 @@ remarks: >- // Sets the color of the selected text range to green. await PowerPoint.run(async (context) => { - const textRange = context.presentation.getSelectedTextRange(); + const textRange: PowerPoint.TextRange = context.presentation.getSelectedTextRange(); textRange.font.color = "green"; await context.sync(); }); @@ -65,7 +65,7 @@ properties: // Sets the color of the selected text range to green. await PowerPoint.run(async (context) => { - const textRange = context.presentation.getSelectedTextRange(); + const textRange: PowerPoint.TextRange = context.presentation.getSelectedTextRange(); textRange.font.color = "green"; await context.sync(); }); @@ -259,21 +259,21 @@ methods: // Selects the first 10 characters of the selected shape. await PowerPoint.run(async (context) => { - const shapes = context.presentation.getSelectedShapes(); + const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes(); const shapeCount = shapes.getCount(); await context.sync(); if (shapeCount.value !== 1) { console.warn("You must select only one shape with text in it."); return; } - const shape = shapes.getItemAt(0); - const textFrame = shape.textFrame.load("textRange,hasText"); + const shape: PowerPoint.Shape = shapes.getItemAt(0); + const textFrame: PowerPoint.TextFrame = shape.textFrame.load("textRange,hasText"); await context.sync(); if (textFrame.hasText != true) { console.warn("You must select only one shape with text in it."); return; } - const textRange = textFrame.textRange; + const textRange: PowerPoint.TextRange = textFrame.textRange; textRange.load("text"); await context.sync(); if (textRange.text.length < 10) { @@ -292,9 +292,9 @@ methods: // Sets the range selection to the range that was saved previously. await PowerPoint.run(async (context) => { - const slide1 = context.presentation.slides.getItem(savedTextSlideSelection[0]); - const shape1 = slide1.shapes.getItem(savedTextShapeSelection[0]); - const textRange = shape1.textFrame.textRange.getSubstring(savedTextTextRangeStart, savedTextTextRangeLength); + 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); textRange.setSelected(); await context.sync(); }); diff --git a/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.textverticalalignment.yml b/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.textverticalalignment.yml index ea4c7baef8..e9c780ca93 100644 --- a/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.textverticalalignment.yml +++ b/docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.textverticalalignment.yml @@ -31,8 +31,8 @@ remarks: >- // color, and centers it inside the braces. await PowerPoint.run(async (context) => { - const shapes = context.presentation.slides.getItemAt(0).shapes; - const braces = shapes.addGeometricShape(PowerPoint.GeometricShapeType.bracePair, { + 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, diff --git a/docs/docs-ref-autogen/powerpoint_1_1/powerpoint/powerpoint.presentation.yml b/docs/docs-ref-autogen/powerpoint_1_1/powerpoint/powerpoint.presentation.yml index 2c4269d924..9d3151f44d 100644 --- a/docs/docs-ref-autogen/powerpoint_1_1/powerpoint/powerpoint.presentation.yml +++ b/docs/docs-ref-autogen/powerpoint_1_1/powerpoint/powerpoint.presentation.yml @@ -19,8 +19,8 @@ remarks: >- await PowerPoint.run(async function(context) { // Get the ID of the first selected slide. - const presentation = context.presentation; - const selected = presentation.getSelectedSlides().getItemAt(0); + const presentation: PowerPoint.Presentation = context.presentation; + const selected: PowerPoint.Slide = presentation.getSelectedSlides().getItemAt(0); selected.load("id"); await context.sync(); diff --git a/docs/docs-ref-autogen/powerpoint_1_2/powerpoint/powerpoint.insertslideformatting.yml b/docs/docs-ref-autogen/powerpoint_1_2/powerpoint/powerpoint.insertslideformatting.yml index c23c7dca4d..e19936d98e 100644 --- a/docs/docs-ref-autogen/powerpoint_1_2/powerpoint/powerpoint.insertslideformatting.yml +++ b/docs/docs-ref-autogen/powerpoint_1_2/powerpoint/powerpoint.insertslideformatting.yml @@ -19,8 +19,8 @@ remarks: >- await PowerPoint.run(async function(context) { // Get the ID of the first selected slide. - const presentation = context.presentation; - const selected = presentation.getSelectedSlides().getItemAt(0); + const presentation: PowerPoint.Presentation = context.presentation; + const selected: PowerPoint.Slide = presentation.getSelectedSlides().getItemAt(0); selected.load("id"); await context.sync(); diff --git a/docs/docs-ref-autogen/powerpoint_1_2/powerpoint/powerpoint.insertslideoptions.yml b/docs/docs-ref-autogen/powerpoint_1_2/powerpoint/powerpoint.insertslideoptions.yml index 1f359cec9d..ea50dfea43 100644 --- a/docs/docs-ref-autogen/powerpoint_1_2/powerpoint/powerpoint.insertslideoptions.yml +++ b/docs/docs-ref-autogen/powerpoint_1_2/powerpoint/powerpoint.insertslideoptions.yml @@ -19,8 +19,8 @@ remarks: >- await PowerPoint.run(async function(context) { // Get the ID of the first selected slide. - const presentation = context.presentation; - const selected = presentation.getSelectedSlides().getItemAt(0); + const presentation: PowerPoint.Presentation = context.presentation; + const selected: PowerPoint.Slide = presentation.getSelectedSlides().getItemAt(0); selected.load("id"); await context.sync(); diff --git a/docs/docs-ref-autogen/powerpoint_1_2/powerpoint/powerpoint.presentation.yml b/docs/docs-ref-autogen/powerpoint_1_2/powerpoint/powerpoint.presentation.yml index 1d21438221..632898c937 100644 --- a/docs/docs-ref-autogen/powerpoint_1_2/powerpoint/powerpoint.presentation.yml +++ b/docs/docs-ref-autogen/powerpoint_1_2/powerpoint/powerpoint.presentation.yml @@ -19,8 +19,8 @@ remarks: >- await PowerPoint.run(async function(context) { // Get the ID of the first selected slide. - const presentation = context.presentation; - const selected = presentation.getSelectedSlides().getItemAt(0); + const presentation: PowerPoint.Presentation = context.presentation; + const selected: PowerPoint.Slide = presentation.getSelectedSlides().getItemAt(0); selected.load("id"); await context.sync(); @@ -97,8 +97,8 @@ methods: await PowerPoint.run(async function(context) { // Get the ID of the first selected slide. - const presentation = context.presentation; - const selected = presentation.getSelectedSlides().getItemAt(0); + const presentation: PowerPoint.Presentation = context.presentation; + const selected: PowerPoint.Slide = presentation.getSelectedSlides().getItemAt(0); selected.load("id"); await context.sync(); diff --git a/docs/docs-ref-autogen/powerpoint_1_2/powerpoint/powerpoint.slide.yml b/docs/docs-ref-autogen/powerpoint_1_2/powerpoint/powerpoint.slide.yml index 08e268618d..df38201c09 100644 --- a/docs/docs-ref-autogen/powerpoint_1_2/powerpoint/powerpoint.slide.yml +++ b/docs/docs-ref-autogen/powerpoint_1_2/powerpoint/powerpoint.slide.yml @@ -20,7 +20,7 @@ remarks: >- // Reselects shapes that were saved previously. await PowerPoint.run(async (context) => { - const slide1 = context.presentation.slides.getItem(savedSlideSelection[0]); + const slide1: PowerPoint.Slide = context.presentation.slides.getItem(savedSlideSelection[0]); await context.sync(); slide1.setSelectedShapes(savedShapeSelection); await context.sync(); @@ -81,7 +81,7 @@ methods: await PowerPoint.run(async (context) => { context.presentation.load("slides"); await context.sync(); - const slides = context.presentation.getSelectedSlides(); + const slides: PowerPoint.SlideScopedCollection = context.presentation.getSelectedSlides(); const slideCount = slides.getCount(); slides.load("items"); await context.sync(); diff --git a/docs/docs-ref-autogen/powerpoint_1_2/powerpoint/powerpoint.slidecollection.yml b/docs/docs-ref-autogen/powerpoint_1_2/powerpoint/powerpoint.slidecollection.yml index 501288edbc..097dce9fa1 100644 --- a/docs/docs-ref-autogen/powerpoint_1_2/powerpoint/powerpoint.slidecollection.yml +++ b/docs/docs-ref-autogen/powerpoint_1_2/powerpoint/powerpoint.slidecollection.yml @@ -119,9 +119,9 @@ methods: await PowerPoint.run(async (context) => { context.presentation.load("slides"); await context.sync(); - const slide2 = context.presentation.slides.getItemAt(1); - const slide4 = context.presentation.slides.getItemAt(3); - const slide5 = context.presentation.slides.getItemAt(4); + const slide2: PowerPoint.Slide = context.presentation.slides.getItemAt(1); + const slide4: PowerPoint.Slide = context.presentation.slides.getItemAt(3); + const slide5: PowerPoint.Slide = context.presentation.slides.getItemAt(4); slide2.load("id"); slide4.load("id"); slide5.load("id"); diff --git a/docs/docs-ref-autogen/powerpoint_1_3/powerpoint/powerpoint.insertslideformatting.yml b/docs/docs-ref-autogen/powerpoint_1_3/powerpoint/powerpoint.insertslideformatting.yml index c23c7dca4d..e19936d98e 100644 --- a/docs/docs-ref-autogen/powerpoint_1_3/powerpoint/powerpoint.insertslideformatting.yml +++ b/docs/docs-ref-autogen/powerpoint_1_3/powerpoint/powerpoint.insertslideformatting.yml @@ -19,8 +19,8 @@ remarks: >- await PowerPoint.run(async function(context) { // Get the ID of the first selected slide. - const presentation = context.presentation; - const selected = presentation.getSelectedSlides().getItemAt(0); + const presentation: PowerPoint.Presentation = context.presentation; + const selected: PowerPoint.Slide = presentation.getSelectedSlides().getItemAt(0); selected.load("id"); await context.sync(); diff --git a/docs/docs-ref-autogen/powerpoint_1_3/powerpoint/powerpoint.insertslideoptions.yml b/docs/docs-ref-autogen/powerpoint_1_3/powerpoint/powerpoint.insertslideoptions.yml index 1f359cec9d..ea50dfea43 100644 --- a/docs/docs-ref-autogen/powerpoint_1_3/powerpoint/powerpoint.insertslideoptions.yml +++ b/docs/docs-ref-autogen/powerpoint_1_3/powerpoint/powerpoint.insertslideoptions.yml @@ -19,8 +19,8 @@ remarks: >- await PowerPoint.run(async function(context) { // Get the ID of the first selected slide. - const presentation = context.presentation; - const selected = presentation.getSelectedSlides().getItemAt(0); + const presentation: PowerPoint.Presentation = context.presentation; + const selected: PowerPoint.Slide = presentation.getSelectedSlides().getItemAt(0); selected.load("id"); await context.sync(); diff --git a/docs/docs-ref-autogen/powerpoint_1_3/powerpoint/powerpoint.presentation.yml b/docs/docs-ref-autogen/powerpoint_1_3/powerpoint/powerpoint.presentation.yml index 1027c1c0d8..f91987eac1 100644 --- a/docs/docs-ref-autogen/powerpoint_1_3/powerpoint/powerpoint.presentation.yml +++ b/docs/docs-ref-autogen/powerpoint_1_3/powerpoint/powerpoint.presentation.yml @@ -19,8 +19,8 @@ remarks: >- await PowerPoint.run(async function(context) { // Get the ID of the first selected slide. - const presentation = context.presentation; - const selected = presentation.getSelectedSlides().getItemAt(0); + const presentation: PowerPoint.Presentation = context.presentation; + const selected: PowerPoint.Slide = presentation.getSelectedSlides().getItemAt(0); selected.load("id"); await context.sync(); @@ -121,8 +121,8 @@ methods: await PowerPoint.run(async function(context) { // Get the ID of the first selected slide. - const presentation = context.presentation; - const selected = presentation.getSelectedSlides().getItemAt(0); + const presentation: PowerPoint.Presentation = context.presentation; + const selected: PowerPoint.Slide = presentation.getSelectedSlides().getItemAt(0); selected.load("id"); await context.sync(); diff --git a/docs/docs-ref-autogen/powerpoint_1_3/powerpoint/powerpoint.shape.yml b/docs/docs-ref-autogen/powerpoint_1_3/powerpoint/powerpoint.shape.yml index a26cca7921..c354425bcf 100644 --- a/docs/docs-ref-autogen/powerpoint_1_3/powerpoint/powerpoint.shape.yml +++ b/docs/docs-ref-autogen/powerpoint_1_3/powerpoint/powerpoint.shape.yml @@ -21,7 +21,7 @@ remarks: >- await PowerPoint.run(async (context) => { // Get the type of shape for every shape in the collection. - const shapes = context.presentation.slides.getItemAt(0).shapes; + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; shapes.load("type"); await context.sync(); @@ -83,7 +83,38 @@ methods: package: powerpoint! fullName: delete() summary: Deletes the shape from the shape collection. Does nothing if the shape does not exist. - remarks: '\[ [API set: PowerPointApi 1.3](/javascript/api/requirement-sets/powerpoint/powerpoint-api-requirement-sets) \]' + remarks: >- + \[ [API set: PowerPointApi 1.3](/javascript/api/requirement-sets/powerpoint/powerpoint-api-requirement-sets) \] + + + #### Examples + + + ```TypeScript + + // 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 then iterates through them, deleting each one. + + await PowerPoint.run(async (context) => { + const slide: PowerPoint.Slide = context.presentation.slides.getItemAt(0); + const shapes: PowerPoint.ShapeCollection = slide.shapes; + + // Load all the shapes in the collection without loading their properties. + shapes.load("items/$none"); + + await context.sync(); + + shapes.items.forEach((shape) => shape.delete()); + + await context.sync(); + }); + + ``` isPreview: false isDeprecated: false syntax: diff --git a/docs/docs-ref-autogen/powerpoint_1_3/powerpoint/powerpoint.shapecollection.yml b/docs/docs-ref-autogen/powerpoint_1_3/powerpoint/powerpoint.shapecollection.yml index 25cd4858e0..18e9b8c599 100644 --- a/docs/docs-ref-autogen/powerpoint_1_3/powerpoint/powerpoint.shapecollection.yml +++ b/docs/docs-ref-autogen/powerpoint_1_3/powerpoint/powerpoint.shapecollection.yml @@ -21,7 +21,7 @@ remarks: >- await PowerPoint.run(async (context) => { // Get the type of shape for every shape in the collection. - const shapes = context.presentation.slides.getItemAt(0).shapes; + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; shapes.load("type"); await context.sync(); @@ -115,13 +115,13 @@ methods: await PowerPoint.run(async function(context) { - const slide = context.presentation.slides.getItemAt(0); - const shape = slide.shapes.getItemAt(0); + const slide: PowerPoint.Slide = context.presentation.slides.getItemAt(0); + const shape: PowerPoint.Shape = slide.shapes.getItemAt(0); shape.tags.add("MOUNTAIN", "Denali"); await context.sync(); - const myShapeTag = shape.tags.getItem("MOUNTAIN"); + const myShapeTag: PowerPoint.Tag = shape.tags.getItem("MOUNTAIN"); myShapeTag.load("key, value"); await context.sync(); @@ -219,7 +219,7 @@ methods: await PowerPoint.run(async (context) => { // Get the type of shape for every shape in the collection. - const shapes = context.presentation.slides.getItemAt(0).shapes; + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; shapes.load("type"); await context.sync(); diff --git a/docs/docs-ref-autogen/powerpoint_1_3/powerpoint/powerpoint.slide.yml b/docs/docs-ref-autogen/powerpoint_1_3/powerpoint/powerpoint.slide.yml index 55b54f7ab3..8d84bc57e9 100644 --- a/docs/docs-ref-autogen/powerpoint_1_3/powerpoint/powerpoint.slide.yml +++ b/docs/docs-ref-autogen/powerpoint_1_3/powerpoint/powerpoint.slide.yml @@ -20,7 +20,7 @@ remarks: >- // Reselects shapes that were saved previously. await PowerPoint.run(async (context) => { - const slide1 = context.presentation.slides.getItem(savedSlideSelection[0]); + const slide1: PowerPoint.Slide = context.presentation.slides.getItem(savedSlideSelection[0]); await context.sync(); slide1.setSelectedShapes(savedShapeSelection); await context.sync(); @@ -129,7 +129,7 @@ methods: await PowerPoint.run(async (context) => { context.presentation.load("slides"); await context.sync(); - const slides = context.presentation.getSelectedSlides(); + const slides: PowerPoint.SlideScopedCollection = context.presentation.getSelectedSlides(); const slideCount = slides.getCount(); slides.load("items"); await context.sync(); diff --git a/docs/docs-ref-autogen/powerpoint_1_3/powerpoint/powerpoint.slidecollection.yml b/docs/docs-ref-autogen/powerpoint_1_3/powerpoint/powerpoint.slidecollection.yml index a59d072763..5b5589f95c 100644 --- a/docs/docs-ref-autogen/powerpoint_1_3/powerpoint/powerpoint.slidecollection.yml +++ b/docs/docs-ref-autogen/powerpoint_1_3/powerpoint/powerpoint.slidecollection.yml @@ -164,9 +164,9 @@ methods: await PowerPoint.run(async (context) => { context.presentation.load("slides"); await context.sync(); - const slide2 = context.presentation.slides.getItemAt(1); - const slide4 = context.presentation.slides.getItemAt(3); - const slide5 = context.presentation.slides.getItemAt(4); + const slide2: PowerPoint.Slide = context.presentation.slides.getItemAt(1); + const slide4: PowerPoint.Slide = context.presentation.slides.getItemAt(3); + const slide5: PowerPoint.Slide = context.presentation.slides.getItemAt(4); slide2.load("id"); slide4.load("id"); slide5.load("id"); diff --git a/docs/docs-ref-autogen/powerpoint_1_3/powerpoint/powerpoint.slidelayout.yml b/docs/docs-ref-autogen/powerpoint_1_3/powerpoint/powerpoint.slidelayout.yml index 1a3058a086..6ad7e506f4 100644 --- a/docs/docs-ref-autogen/powerpoint_1_3/powerpoint/powerpoint.slidelayout.yml +++ b/docs/docs-ref-autogen/powerpoint_1_3/powerpoint/powerpoint.slidelayout.yml @@ -19,7 +19,7 @@ remarks: >- await PowerPoint.run(async function(context) { // Load information about all the slide masters and associated layouts. - const slideMasters = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); + const slideMasters: PowerPoint.SlideMasterCollection = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); await context.sync(); // Log the name and ID of each slide master. @@ -28,7 +28,7 @@ remarks: >- console.log("Master ID: " + slideMasters.items[i].id); // Log the name and ID of each slide layout in the slide master. - const layoutsInMaster = slideMasters.items[i].layouts; + const layoutsInMaster: PowerPoint.SlideLayoutCollection = slideMasters.items[i].layouts; for (let j = 0; j < layoutsInMaster.items.length; j++) { console.log(" Layout name: " + layoutsInMaster.items[j].name + " Layout ID: " + layoutsInMaster.items[j].id); } @@ -74,7 +74,7 @@ properties: await PowerPoint.run(async function(context) { // Load information about all the slide masters and associated layouts. - const slideMasters = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); + const slideMasters: PowerPoint.SlideMasterCollection = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); await context.sync(); // Log the name and ID of each slide master. @@ -83,7 +83,7 @@ properties: console.log("Master ID: " + slideMasters.items[i].id); // Log the name and ID of each slide layout in the slide master. - const layoutsInMaster = slideMasters.items[i].layouts; + const layoutsInMaster: PowerPoint.SlideLayoutCollection = slideMasters.items[i].layouts; for (let j = 0; j < layoutsInMaster.items.length; j++) { console.log(" Layout name: " + layoutsInMaster.items[j].name + " Layout ID: " + layoutsInMaster.items[j].id); } diff --git a/docs/docs-ref-autogen/powerpoint_1_3/powerpoint/powerpoint.slidelayoutcollection.yml b/docs/docs-ref-autogen/powerpoint_1_3/powerpoint/powerpoint.slidelayoutcollection.yml index b67d17fba0..7076f35327 100644 --- a/docs/docs-ref-autogen/powerpoint_1_3/powerpoint/powerpoint.slidelayoutcollection.yml +++ b/docs/docs-ref-autogen/powerpoint_1_3/powerpoint/powerpoint.slidelayoutcollection.yml @@ -19,7 +19,7 @@ remarks: >- await PowerPoint.run(async function(context) { // Load information about all the slide masters and associated layouts. - const slideMasters = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); + const slideMasters: PowerPoint.SlideMasterCollection = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); await context.sync(); // Log the name and ID of each slide master. @@ -28,7 +28,7 @@ remarks: >- console.log("Master ID: " + slideMasters.items[i].id); // Log the name and ID of each slide layout in the slide master. - const layoutsInMaster = slideMasters.items[i].layouts; + const layoutsInMaster: PowerPoint.SlideLayoutCollection = slideMasters.items[i].layouts; for (let j = 0; j < layoutsInMaster.items.length; j++) { console.log(" Layout name: " + layoutsInMaster.items[j].name + " Layout ID: " + layoutsInMaster.items[j].id); } @@ -190,7 +190,7 @@ methods: await PowerPoint.run(async function(context) { // Load information about all the slide masters and associated layouts. - const slideMasters = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); + const slideMasters: PowerPoint.SlideMasterCollection = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); await context.sync(); // Log the name and ID of each slide master. @@ -199,7 +199,7 @@ methods: console.log("Master ID: " + slideMasters.items[i].id); // Log the name and ID of each slide layout in the slide master. - const layoutsInMaster = slideMasters.items[i].layouts; + const layoutsInMaster: PowerPoint.SlideLayoutCollection = slideMasters.items[i].layouts; for (let j = 0; j < layoutsInMaster.items.length; j++) { console.log(" Layout name: " + layoutsInMaster.items[j].name + " Layout ID: " + layoutsInMaster.items[j].id); } diff --git a/docs/docs-ref-autogen/powerpoint_1_3/powerpoint/powerpoint.slidemaster.yml b/docs/docs-ref-autogen/powerpoint_1_3/powerpoint/powerpoint.slidemaster.yml index 5f8c223a24..400340ed76 100644 --- a/docs/docs-ref-autogen/powerpoint_1_3/powerpoint/powerpoint.slidemaster.yml +++ b/docs/docs-ref-autogen/powerpoint_1_3/powerpoint/powerpoint.slidemaster.yml @@ -19,7 +19,7 @@ remarks: >- await PowerPoint.run(async function(context) { // Load information about all the slide masters and associated layouts. - const slideMasters = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); + const slideMasters: PowerPoint.SlideMasterCollection = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); await context.sync(); // Log the name and ID of each slide master. @@ -28,7 +28,7 @@ remarks: >- console.log("Master ID: " + slideMasters.items[i].id); // Log the name and ID of each slide layout in the slide master. - const layoutsInMaster = slideMasters.items[i].layouts; + const layoutsInMaster: PowerPoint.SlideLayoutCollection = slideMasters.items[i].layouts; for (let j = 0; j < layoutsInMaster.items.length; j++) { console.log(" Layout name: " + layoutsInMaster.items[j].name + " Layout ID: " + layoutsInMaster.items[j].id); } @@ -74,7 +74,7 @@ properties: await PowerPoint.run(async function(context) { // Load information about all the slide masters and associated layouts. - const slideMasters = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); + const slideMasters: PowerPoint.SlideMasterCollection = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); await context.sync(); // Log the name and ID of each slide master. @@ -83,7 +83,7 @@ properties: console.log("Master ID: " + slideMasters.items[i].id); // Log the name and ID of each slide layout in the slide master. - const layoutsInMaster = slideMasters.items[i].layouts; + const layoutsInMaster: PowerPoint.SlideLayoutCollection = slideMasters.items[i].layouts; for (let j = 0; j < layoutsInMaster.items.length; j++) { console.log(" Layout name: " + layoutsInMaster.items[j].name + " Layout ID: " + layoutsInMaster.items[j].id); } diff --git a/docs/docs-ref-autogen/powerpoint_1_3/powerpoint/powerpoint.slidemastercollection.yml b/docs/docs-ref-autogen/powerpoint_1_3/powerpoint/powerpoint.slidemastercollection.yml index 8f3aef0c34..f3022d8d5b 100644 --- a/docs/docs-ref-autogen/powerpoint_1_3/powerpoint/powerpoint.slidemastercollection.yml +++ b/docs/docs-ref-autogen/powerpoint_1_3/powerpoint/powerpoint.slidemastercollection.yml @@ -19,7 +19,7 @@ remarks: >- await PowerPoint.run(async function(context) { // Load information about all the slide masters and associated layouts. - const slideMasters = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); + const slideMasters: PowerPoint.SlideMasterCollection = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); await context.sync(); // Log the name and ID of each slide master. @@ -28,7 +28,7 @@ remarks: >- console.log("Master ID: " + slideMasters.items[i].id); // Log the name and ID of each slide layout in the slide master. - const layoutsInMaster = slideMasters.items[i].layouts; + const layoutsInMaster: PowerPoint.SlideLayoutCollection = slideMasters.items[i].layouts; for (let j = 0; j < layoutsInMaster.items.length; j++) { console.log(" Layout name: " + layoutsInMaster.items[j].name + " Layout ID: " + layoutsInMaster.items[j].id); } @@ -190,7 +190,7 @@ methods: await PowerPoint.run(async function(context) { // Load information about all the slide masters and associated layouts. - const slideMasters = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); + const slideMasters: PowerPoint.SlideMasterCollection = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); await context.sync(); // Log the name and ID of each slide master. @@ -199,7 +199,7 @@ methods: console.log("Master ID: " + slideMasters.items[i].id); // Log the name and ID of each slide layout in the slide master. - const layoutsInMaster = slideMasters.items[i].layouts; + const layoutsInMaster: PowerPoint.SlideLayoutCollection = slideMasters.items[i].layouts; for (let j = 0; j < layoutsInMaster.items.length; j++) { console.log(" Layout name: " + layoutsInMaster.items[j].name + " Layout ID: " + layoutsInMaster.items[j].id); } diff --git a/docs/docs-ref-autogen/powerpoint_1_3/powerpoint/powerpoint.tag.yml b/docs/docs-ref-autogen/powerpoint_1_3/powerpoint/powerpoint.tag.yml index b1fb1165ab..58489cace5 100644 --- a/docs/docs-ref-autogen/powerpoint_1_3/powerpoint/powerpoint.tag.yml +++ b/docs/docs-ref-autogen/powerpoint_1_3/powerpoint/powerpoint.tag.yml @@ -4,7 +4,34 @@ uid: 'powerpoint!PowerPoint.Tag:class' package: powerpoint! fullName: PowerPoint.Tag summary: Represents a single tag in the slide. -remarks: '\[ [API set: PowerPointApi 1.3](/javascript/api/requirement-sets/powerpoint/powerpoint-api-requirement-sets) \]' +remarks: >- + \[ [API set: PowerPointApi 1.3](/javascript/api/requirement-sets/powerpoint/powerpoint-api-requirement-sets) \] + + + #### Examples + + + ```TypeScript + + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/tags/tags.yaml + + + await PowerPoint.run(async function (context) { + let presentationTags: PowerPoint.TagCollection = context.presentation.tags; + presentationTags.add("COLOR", "blue"); + + await context.sync(); + + const tag: PowerPoint.Tag = presentationTags.getItem("COLOR"); + tag.load("key, value"); + + await context.sync(); + + console.log("Added key " + JSON.stringify(tag.key) + " with value " + JSON.stringify(tag.value)); + }); + + ``` isPreview: false isDeprecated: false type: class diff --git a/docs/docs-ref-autogen/powerpoint_1_3/powerpoint/powerpoint.tagcollection.yml b/docs/docs-ref-autogen/powerpoint_1_3/powerpoint/powerpoint.tagcollection.yml index 81adc1217a..a454993603 100644 --- a/docs/docs-ref-autogen/powerpoint_1_3/powerpoint/powerpoint.tagcollection.yml +++ b/docs/docs-ref-autogen/powerpoint_1_3/powerpoint/powerpoint.tagcollection.yml @@ -23,12 +23,12 @@ remarks: >- // Decrement because the getSelectedSlideByIndex method is 1-based, // but the getItemAt method is 0-based. selectedSlideIndex = selectedSlideIndex - 1; - const slide = context.presentation.slides.getItemAt(selectedSlideIndex); + const slide: PowerPoint.Slide = context.presentation.slides.getItemAt(selectedSlideIndex); slide.tags.add("CUSTOMER_TYPE", "Premium"); await context.sync(); - const audienceTag = slide.tags.getItem("CUSTOMER_TYPE"); + const audienceTag: PowerPoint.Tag = slide.tags.getItem("CUSTOMER_TYPE"); audienceTag.load("key, value"); await context.sync(); @@ -89,7 +89,7 @@ methods: await PowerPoint.run(async function(context) { - const slide = context.presentation.slides.getItemAt(0); + const slide: PowerPoint.Slide = context.presentation.slides.getItemAt(0); slide.tags.add("OCEAN", "Indian"); slide.tags.add("PLANET", "Jupiter"); slide.tags.add("CONTINENT", "Antarctica"); @@ -141,7 +141,7 @@ methods: await PowerPoint.run(async function (context) { - let presentationTags = context.presentation.tags; + let presentationTags: PowerPoint.TagCollection = context.presentation.tags; presentationTags.delete("COLOR"); @@ -201,12 +201,12 @@ methods: // Decrement because the getSelectedSlideByIndex method is 1-based, // but the getItemAt method is 0-based. selectedSlideIndex = selectedSlideIndex - 1; - const slide = context.presentation.slides.getItemAt(selectedSlideIndex); + const slide: PowerPoint.Slide = context.presentation.slides.getItemAt(selectedSlideIndex); slide.tags.add("CUSTOMER_TYPE", "Premium"); await context.sync(); - const audienceTag = slide.tags.getItem("CUSTOMER_TYPE"); + const audienceTag: PowerPoint.Tag = slide.tags.getItem("CUSTOMER_TYPE"); audienceTag.load("key, value"); await context.sync(); diff --git a/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.connectortype.yml b/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.connectortype.yml index 8a0a750565..7b30df9b51 100644 --- a/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.connectortype.yml +++ b/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.connectortype.yml @@ -24,11 +24,11 @@ remarks: >- // start and end points. Then it names the shape. await PowerPoint.run(async (context) => { - const shapes = context.presentation.slides.getItemAt(0).shapes; + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; // 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 = shapes.addLine(PowerPoint.ConnectorType.straight, + const line: PowerPoint.Shape = shapes.addLine(PowerPoint.ConnectorType.straight, { left: 400, top: 200, diff --git a/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.geometricshapetype.yml b/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.geometricshapetype.yml index b060114f7e..46f2a39913 100644 --- a/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.geometricshapetype.yml +++ b/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.geometricshapetype.yml @@ -24,14 +24,14 @@ remarks: >- // location and size. Then it names the shape. await PowerPoint.run(async (context) => { - const shapes = context.presentation.slides.getItemAt(0).shapes; - const hexagon = shapes.addGeometricShape(PowerPoint.GeometricShapeType.hexagon, - { - left: 100, - top: 100, - height: 150, - width: 150 - }); + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; + const shapeOptions: PowerPoint.ShapeAddOptions = { + left: 100, + top: 100, + height: 150, + width: 150 + }; + const hexagon: PowerPoint.Shape = shapes.addGeometricShape(PowerPoint.GeometricShapeType.hexagon, shapeOptions); hexagon.name = "Hexagon"; await context.sync(); diff --git a/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.insertslideformatting.yml b/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.insertslideformatting.yml index c23c7dca4d..e19936d98e 100644 --- a/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.insertslideformatting.yml +++ b/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.insertslideformatting.yml @@ -19,8 +19,8 @@ remarks: >- await PowerPoint.run(async function(context) { // Get the ID of the first selected slide. - const presentation = context.presentation; - const selected = presentation.getSelectedSlides().getItemAt(0); + const presentation: PowerPoint.Presentation = context.presentation; + const selected: PowerPoint.Slide = presentation.getSelectedSlides().getItemAt(0); selected.load("id"); await context.sync(); diff --git a/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.insertslideoptions.yml b/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.insertslideoptions.yml index 1f359cec9d..ea50dfea43 100644 --- a/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.insertslideoptions.yml +++ b/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.insertslideoptions.yml @@ -19,8 +19,8 @@ remarks: >- await PowerPoint.run(async function(context) { // Get the ID of the first selected slide. - const presentation = context.presentation; - const selected = presentation.getSelectedSlides().getItemAt(0); + const presentation: PowerPoint.Presentation = context.presentation; + const selected: PowerPoint.Slide = presentation.getSelectedSlides().getItemAt(0); selected.load("id"); await context.sync(); diff --git a/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.presentation.yml b/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.presentation.yml index 1027c1c0d8..f91987eac1 100644 --- a/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.presentation.yml +++ b/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.presentation.yml @@ -19,8 +19,8 @@ remarks: >- await PowerPoint.run(async function(context) { // Get the ID of the first selected slide. - const presentation = context.presentation; - const selected = presentation.getSelectedSlides().getItemAt(0); + const presentation: PowerPoint.Presentation = context.presentation; + const selected: PowerPoint.Slide = presentation.getSelectedSlides().getItemAt(0); selected.load("id"); await context.sync(); @@ -121,8 +121,8 @@ methods: await PowerPoint.run(async function(context) { // Get the ID of the first selected slide. - const presentation = context.presentation; - const selected = presentation.getSelectedSlides().getItemAt(0); + const presentation: PowerPoint.Presentation = context.presentation; + const selected: PowerPoint.Slide = presentation.getSelectedSlides().getItemAt(0); selected.load("id"); await context.sync(); diff --git a/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.shape.yml b/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.shape.yml index f740f9ad7f..e3db0cae6d 100644 --- a/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.shape.yml +++ b/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.shape.yml @@ -21,7 +21,7 @@ remarks: >- await PowerPoint.run(async (context) => { // Get the type of shape for every shape in the collection. - const shapes = context.presentation.slides.getItemAt(0).shapes; + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; shapes.load("type"); await context.sync(); @@ -74,7 +74,7 @@ properties: // Changes the selected shapes fill color to red. await PowerPoint.run(async (context) => { - const shapes = context.presentation.getSelectedShapes(); + const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes(); const shapeCount = shapes.getCount(); shapes.load("items"); await context.sync(); @@ -114,7 +114,7 @@ properties: // Arranges the selected shapes in a line from left to right. await PowerPoint.run(async (context) => { - const shapes = context.presentation.getSelectedShapes(); + const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes(); const shapeCount = shapes.getCount(); shapes.load("items"); await context.sync(); @@ -174,7 +174,7 @@ properties: // Arranges the selected shapes in a line from left to right. await PowerPoint.run(async (context) => { - const shapes = context.presentation.getSelectedShapes(); + const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes(); const shapeCount = shapes.getCount(); shapes.load("items"); await context.sync(); @@ -270,7 +270,7 @@ properties: // Arranges the selected shapes in a line from left to right. await PowerPoint.run(async (context) => { - const shapes = context.presentation.getSelectedShapes(); + const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes(); const shapeCount = shapes.getCount(); shapes.load("items"); await context.sync(); @@ -319,7 +319,7 @@ properties: await PowerPoint.run(async (context) => { // Get the type of shape for every shape in the collection. - const shapes = context.presentation.slides.getItemAt(0).shapes; + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; shapes.load("type"); await context.sync(); @@ -364,7 +364,7 @@ properties: // Arranges the selected shapes in a line from left to right. await PowerPoint.run(async (context) => { - const shapes = context.presentation.getSelectedShapes(); + const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes(); const shapeCount = shapes.getCount(); shapes.load("items"); await context.sync(); @@ -397,7 +397,38 @@ methods: package: powerpoint! fullName: delete() summary: Deletes the shape from the shape collection. Does nothing if the shape does not exist. - remarks: '\[ [API set: PowerPointApi 1.3](/javascript/api/requirement-sets/powerpoint/powerpoint-api-requirement-sets) \]' + remarks: >- + \[ [API set: PowerPointApi 1.3](/javascript/api/requirement-sets/powerpoint/powerpoint-api-requirement-sets) \] + + + #### Examples + + + ```TypeScript + + // 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 then iterates through them, deleting each one. + + await PowerPoint.run(async (context) => { + const slide: PowerPoint.Slide = context.presentation.slides.getItemAt(0); + const shapes: PowerPoint.ShapeCollection = slide.shapes; + + // Load all the shapes in the collection without loading their properties. + shapes.load("items/$none"); + + await context.sync(); + + shapes.items.forEach((shape) => shape.delete()); + + await context.sync(); + }); + + ``` isPreview: false isDeprecated: false syntax: diff --git a/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.shapeaddoptions.yml b/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.shapeaddoptions.yml index 241f97b00f..d492e51cf7 100644 --- a/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.shapeaddoptions.yml +++ b/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.shapeaddoptions.yml @@ -4,7 +4,40 @@ uid: 'powerpoint!PowerPoint.ShapeAddOptions:interface' package: powerpoint! fullName: PowerPoint.ShapeAddOptions summary: Represents the available options when adding shapes. -remarks: '\[ [API set: PowerPointApi 1.4](/javascript/api/requirement-sets/powerpoint/powerpoint-api-requirement-sets) \]' +remarks: >- + \[ [API set: PowerPointApi 1.4](/javascript/api/requirement-sets/powerpoint/powerpoint-api-requirement-sets) \] + + + #### Examples + + + ```TypeScript + + // 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 hexagon shape to the collection, while specifying its + + // location and size. Then it names the shape. + + await PowerPoint.run(async (context) => { + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; + const shapeOptions: PowerPoint.ShapeAddOptions = { + left: 100, + top: 100, + height: 150, + width: 150 + }; + const hexagon: PowerPoint.Shape = shapes.addGeometricShape(PowerPoint.GeometricShapeType.hexagon, shapeOptions); + hexagon.name = "Hexagon"; + + await context.sync(); + }); + + ``` isPreview: false isDeprecated: false type: interface diff --git a/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.shapecollection.yml b/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.shapecollection.yml index 8931536b96..a5efe8e5ec 100644 --- a/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.shapecollection.yml +++ b/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.shapecollection.yml @@ -21,7 +21,7 @@ remarks: >- await PowerPoint.run(async (context) => { // Get the type of shape for every shape in the collection. - const shapes = context.presentation.slides.getItemAt(0).shapes; + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; shapes.load("type"); await context.sync(); @@ -91,14 +91,14 @@ methods: // location and size. Then it names the shape. await PowerPoint.run(async (context) => { - const shapes = context.presentation.slides.getItemAt(0).shapes; - const hexagon = shapes.addGeometricShape(PowerPoint.GeometricShapeType.hexagon, - { - left: 100, - top: 100, - height: 150, - width: 150 - }); + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; + const shapeOptions: PowerPoint.ShapeAddOptions = { + left: 100, + top: 100, + height: 150, + width: 150 + }; + const hexagon: PowerPoint.Shape = shapes.addGeometricShape(PowerPoint.GeometricShapeType.hexagon, shapeOptions); hexagon.name = "Hexagon"; await context.sync(); @@ -232,11 +232,11 @@ methods: // start and end points. Then it names the shape. await PowerPoint.run(async (context) => { - const shapes = context.presentation.slides.getItemAt(0).shapes; + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; // 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 = shapes.addLine(PowerPoint.ConnectorType.straight, + const line: PowerPoint.Shape = shapes.addLine(PowerPoint.ConnectorType.straight, { left: 400, top: 200, @@ -320,8 +320,8 @@ methods: // location, and size. Then it names the text box. await PowerPoint.run(async (context) => { - const shapes = context.presentation.slides.getItemAt(0).shapes; - const textbox = shapes.addTextBox("Hello!", + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; + const textbox: PowerPoint.Shape = shapes.addTextBox("Hello!", { left: 100, top: 300, @@ -397,13 +397,13 @@ methods: await PowerPoint.run(async function(context) { - const slide = context.presentation.slides.getItemAt(0); - const shape = slide.shapes.getItemAt(0); + const slide: PowerPoint.Slide = context.presentation.slides.getItemAt(0); + const shape: PowerPoint.Shape = slide.shapes.getItemAt(0); shape.tags.add("MOUNTAIN", "Denali"); await context.sync(); - const myShapeTag = shape.tags.getItem("MOUNTAIN"); + const myShapeTag: PowerPoint.Tag = shape.tags.getItem("MOUNTAIN"); myShapeTag.load("key, value"); await context.sync(); @@ -501,7 +501,7 @@ methods: await PowerPoint.run(async (context) => { // Get the type of shape for every shape in the collection. - const shapes = context.presentation.slides.getItemAt(0).shapes; + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; shapes.load("type"); await context.sync(); diff --git a/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.shapefill.yml b/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.shapefill.yml index bf9d6a34aa..923dd0585d 100644 --- a/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.shapefill.yml +++ b/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.shapefill.yml @@ -21,7 +21,7 @@ remarks: >- await PowerPoint.run(async (context) => { // Get the type of shape for every shape in the collection. - const shapes = context.presentation.slides.getItemAt(0).shapes; + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; shapes.load("type"); await context.sync(); @@ -60,7 +60,42 @@ properties: summary: >- 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"). - remarks: '\[ [API set: PowerPointApi 1.4](/javascript/api/requirement-sets/powerpoint/powerpoint-api-requirement-sets) \]' + remarks: >- + \[ [API set: PowerPointApi 1.4](/javascript/api/requirement-sets/powerpoint/powerpoint-api-requirement-sets) \] + + + #### Examples + + + ```TypeScript + + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/get-set-shapes.yaml + + + // Creates random shapes on the selected slide. + + await PowerPoint.run(async (context) => { + let finalTable = ""; + const currentSlide: PowerPoint.Slide = context.presentation.getSelectedSlides().getItemAt(0); + const maxNewShapeWidth = 200; + const maxNewShapeHeight = 200; + const minNewShapeWidth = 50; + const minNewShapeHeight = 50; + for (let i = 0; i < 20; i++) { + const rectangle: PowerPoint.Shape = currentSlide.shapes.addGeometricShape(PowerPoint.GeometricShapeType.rectangle); + rectangle.height = getRandomBetween(minNewShapeWidth, maxNewShapeWidth); + rectangle.width = getRandomBetween(minNewShapeHeight, maxNewShapeHeight); + rectangle.left = getRandomBetween(0, slideWidth - rectangle.width); + rectangle.top = getRandomBetween(0, slideHeight - rectangle.height); + rectangle.fill.foregroundColor = generateRandomHexColor(); + } + finalTable += "Done
"; + $("#slide-tags").empty(); + $("#slide-tags").append(finalTable); + }); + + ``` isPreview: false isDeprecated: false syntax: @@ -92,7 +127,7 @@ properties: await PowerPoint.run(async (context) => { // Get the type of shape for every shape in the collection. - const shapes = context.presentation.slides.getItemAt(0).shapes; + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; shapes.load("type"); await context.sync(); @@ -232,7 +267,7 @@ methods: // Changes the selected shapes fill color to red. await PowerPoint.run(async (context) => { - const shapes = context.presentation.getSelectedShapes(); + const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes(); const shapeCount = shapes.getCount(); shapes.load("items"); await context.sync(); diff --git a/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.shapefont.yml b/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.shapefont.yml index f74d0f3e9a..1445929e14 100644 --- a/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.shapefont.yml +++ b/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.shapefont.yml @@ -20,7 +20,7 @@ remarks: >- // Sets the color of the selected text range to green. await PowerPoint.run(async (context) => { - const textRange = context.presentation.getSelectedTextRange(); + const textRange: PowerPoint.TextRange = context.presentation.getSelectedTextRange(); textRange.font.color = "green"; await context.sync(); }); @@ -67,7 +67,7 @@ properties: // Sets the color of the selected text range to green. await PowerPoint.run(async (context) => { - const textRange = context.presentation.getSelectedTextRange(); + const textRange: PowerPoint.TextRange = context.presentation.getSelectedTextRange(); textRange.font.color = "green"; await context.sync(); }); diff --git a/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.shapelinedashstyle.yml b/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.shapelinedashstyle.yml index 7d6be56a1f..d45033c2f5 100644 --- a/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.shapelinedashstyle.yml +++ b/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.shapelinedashstyle.yml @@ -21,7 +21,7 @@ remarks: >- await PowerPoint.run(async (context) => { // Get the type of shape for every shape in the collection. - const shapes = context.presentation.slides.getItemAt(0).shapes; + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; shapes.load("type"); await context.sync(); diff --git a/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.shapelineformat.yml b/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.shapelineformat.yml index 813e163050..1c689d7ca6 100644 --- a/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.shapelineformat.yml +++ b/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.shapelineformat.yml @@ -23,7 +23,7 @@ remarks: >- await PowerPoint.run(async (context) => { // Get the type of shape for every shape in the collection. - const shapes = context.presentation.slides.getItemAt(0).shapes; + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; shapes.load("type"); await context.sync(); @@ -93,7 +93,7 @@ properties: await PowerPoint.run(async (context) => { // Get the type of shape for every shape in the collection. - const shapes = context.presentation.slides.getItemAt(0).shapes; + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; shapes.load("type"); await context.sync(); diff --git a/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.shapetype.yml b/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.shapetype.yml index aed58db05c..c594c61330 100644 --- a/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.shapetype.yml +++ b/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.shapetype.yml @@ -21,7 +21,7 @@ remarks: >- await PowerPoint.run(async (context) => { // Get the type of shape for every shape in the collection. - const shapes = context.presentation.slides.getItemAt(0).shapes; + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; shapes.load("type"); await context.sync(); diff --git a/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.slide.yml b/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.slide.yml index 55b54f7ab3..8d84bc57e9 100644 --- a/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.slide.yml +++ b/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.slide.yml @@ -20,7 +20,7 @@ remarks: >- // Reselects shapes that were saved previously. await PowerPoint.run(async (context) => { - const slide1 = context.presentation.slides.getItem(savedSlideSelection[0]); + const slide1: PowerPoint.Slide = context.presentation.slides.getItem(savedSlideSelection[0]); await context.sync(); slide1.setSelectedShapes(savedShapeSelection); await context.sync(); @@ -129,7 +129,7 @@ methods: await PowerPoint.run(async (context) => { context.presentation.load("slides"); await context.sync(); - const slides = context.presentation.getSelectedSlides(); + const slides: PowerPoint.SlideScopedCollection = context.presentation.getSelectedSlides(); const slideCount = slides.getCount(); slides.load("items"); await context.sync(); diff --git a/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.slidecollection.yml b/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.slidecollection.yml index a59d072763..5b5589f95c 100644 --- a/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.slidecollection.yml +++ b/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.slidecollection.yml @@ -164,9 +164,9 @@ methods: await PowerPoint.run(async (context) => { context.presentation.load("slides"); await context.sync(); - const slide2 = context.presentation.slides.getItemAt(1); - const slide4 = context.presentation.slides.getItemAt(3); - const slide5 = context.presentation.slides.getItemAt(4); + const slide2: PowerPoint.Slide = context.presentation.slides.getItemAt(1); + const slide4: PowerPoint.Slide = context.presentation.slides.getItemAt(3); + const slide5: PowerPoint.Slide = context.presentation.slides.getItemAt(4); slide2.load("id"); slide4.load("id"); slide5.load("id"); diff --git a/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.slidelayout.yml b/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.slidelayout.yml index 1a3058a086..6ad7e506f4 100644 --- a/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.slidelayout.yml +++ b/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.slidelayout.yml @@ -19,7 +19,7 @@ remarks: >- await PowerPoint.run(async function(context) { // Load information about all the slide masters and associated layouts. - const slideMasters = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); + const slideMasters: PowerPoint.SlideMasterCollection = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); await context.sync(); // Log the name and ID of each slide master. @@ -28,7 +28,7 @@ remarks: >- console.log("Master ID: " + slideMasters.items[i].id); // Log the name and ID of each slide layout in the slide master. - const layoutsInMaster = slideMasters.items[i].layouts; + const layoutsInMaster: PowerPoint.SlideLayoutCollection = slideMasters.items[i].layouts; for (let j = 0; j < layoutsInMaster.items.length; j++) { console.log(" Layout name: " + layoutsInMaster.items[j].name + " Layout ID: " + layoutsInMaster.items[j].id); } @@ -74,7 +74,7 @@ properties: await PowerPoint.run(async function(context) { // Load information about all the slide masters and associated layouts. - const slideMasters = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); + const slideMasters: PowerPoint.SlideMasterCollection = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); await context.sync(); // Log the name and ID of each slide master. @@ -83,7 +83,7 @@ properties: console.log("Master ID: " + slideMasters.items[i].id); // Log the name and ID of each slide layout in the slide master. - const layoutsInMaster = slideMasters.items[i].layouts; + const layoutsInMaster: PowerPoint.SlideLayoutCollection = slideMasters.items[i].layouts; for (let j = 0; j < layoutsInMaster.items.length; j++) { console.log(" Layout name: " + layoutsInMaster.items[j].name + " Layout ID: " + layoutsInMaster.items[j].id); } diff --git a/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.slidelayoutcollection.yml b/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.slidelayoutcollection.yml index b67d17fba0..7076f35327 100644 --- a/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.slidelayoutcollection.yml +++ b/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.slidelayoutcollection.yml @@ -19,7 +19,7 @@ remarks: >- await PowerPoint.run(async function(context) { // Load information about all the slide masters and associated layouts. - const slideMasters = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); + const slideMasters: PowerPoint.SlideMasterCollection = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); await context.sync(); // Log the name and ID of each slide master. @@ -28,7 +28,7 @@ remarks: >- console.log("Master ID: " + slideMasters.items[i].id); // Log the name and ID of each slide layout in the slide master. - const layoutsInMaster = slideMasters.items[i].layouts; + const layoutsInMaster: PowerPoint.SlideLayoutCollection = slideMasters.items[i].layouts; for (let j = 0; j < layoutsInMaster.items.length; j++) { console.log(" Layout name: " + layoutsInMaster.items[j].name + " Layout ID: " + layoutsInMaster.items[j].id); } @@ -190,7 +190,7 @@ methods: await PowerPoint.run(async function(context) { // Load information about all the slide masters and associated layouts. - const slideMasters = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); + const slideMasters: PowerPoint.SlideMasterCollection = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); await context.sync(); // Log the name and ID of each slide master. @@ -199,7 +199,7 @@ methods: console.log("Master ID: " + slideMasters.items[i].id); // Log the name and ID of each slide layout in the slide master. - const layoutsInMaster = slideMasters.items[i].layouts; + const layoutsInMaster: PowerPoint.SlideLayoutCollection = slideMasters.items[i].layouts; for (let j = 0; j < layoutsInMaster.items.length; j++) { console.log(" Layout name: " + layoutsInMaster.items[j].name + " Layout ID: " + layoutsInMaster.items[j].id); } diff --git a/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.slidemaster.yml b/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.slidemaster.yml index 5f8c223a24..400340ed76 100644 --- a/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.slidemaster.yml +++ b/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.slidemaster.yml @@ -19,7 +19,7 @@ remarks: >- await PowerPoint.run(async function(context) { // Load information about all the slide masters and associated layouts. - const slideMasters = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); + const slideMasters: PowerPoint.SlideMasterCollection = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); await context.sync(); // Log the name and ID of each slide master. @@ -28,7 +28,7 @@ remarks: >- console.log("Master ID: " + slideMasters.items[i].id); // Log the name and ID of each slide layout in the slide master. - const layoutsInMaster = slideMasters.items[i].layouts; + const layoutsInMaster: PowerPoint.SlideLayoutCollection = slideMasters.items[i].layouts; for (let j = 0; j < layoutsInMaster.items.length; j++) { console.log(" Layout name: " + layoutsInMaster.items[j].name + " Layout ID: " + layoutsInMaster.items[j].id); } @@ -74,7 +74,7 @@ properties: await PowerPoint.run(async function(context) { // Load information about all the slide masters and associated layouts. - const slideMasters = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); + const slideMasters: PowerPoint.SlideMasterCollection = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); await context.sync(); // Log the name and ID of each slide master. @@ -83,7 +83,7 @@ properties: console.log("Master ID: " + slideMasters.items[i].id); // Log the name and ID of each slide layout in the slide master. - const layoutsInMaster = slideMasters.items[i].layouts; + const layoutsInMaster: PowerPoint.SlideLayoutCollection = slideMasters.items[i].layouts; for (let j = 0; j < layoutsInMaster.items.length; j++) { console.log(" Layout name: " + layoutsInMaster.items[j].name + " Layout ID: " + layoutsInMaster.items[j].id); } diff --git a/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.slidemastercollection.yml b/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.slidemastercollection.yml index 8f3aef0c34..f3022d8d5b 100644 --- a/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.slidemastercollection.yml +++ b/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.slidemastercollection.yml @@ -19,7 +19,7 @@ remarks: >- await PowerPoint.run(async function(context) { // Load information about all the slide masters and associated layouts. - const slideMasters = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); + const slideMasters: PowerPoint.SlideMasterCollection = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); await context.sync(); // Log the name and ID of each slide master. @@ -28,7 +28,7 @@ remarks: >- console.log("Master ID: " + slideMasters.items[i].id); // Log the name and ID of each slide layout in the slide master. - const layoutsInMaster = slideMasters.items[i].layouts; + const layoutsInMaster: PowerPoint.SlideLayoutCollection = slideMasters.items[i].layouts; for (let j = 0; j < layoutsInMaster.items.length; j++) { console.log(" Layout name: " + layoutsInMaster.items[j].name + " Layout ID: " + layoutsInMaster.items[j].id); } @@ -190,7 +190,7 @@ methods: await PowerPoint.run(async function(context) { // Load information about all the slide masters and associated layouts. - const slideMasters = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); + const slideMasters: PowerPoint.SlideMasterCollection = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); await context.sync(); // Log the name and ID of each slide master. @@ -199,7 +199,7 @@ methods: console.log("Master ID: " + slideMasters.items[i].id); // Log the name and ID of each slide layout in the slide master. - const layoutsInMaster = slideMasters.items[i].layouts; + const layoutsInMaster: PowerPoint.SlideLayoutCollection = slideMasters.items[i].layouts; for (let j = 0; j < layoutsInMaster.items.length; j++) { console.log(" Layout name: " + layoutsInMaster.items[j].name + " Layout ID: " + layoutsInMaster.items[j].id); } diff --git a/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.tag.yml b/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.tag.yml index b1fb1165ab..58489cace5 100644 --- a/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.tag.yml +++ b/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.tag.yml @@ -4,7 +4,34 @@ uid: 'powerpoint!PowerPoint.Tag:class' package: powerpoint! fullName: PowerPoint.Tag summary: Represents a single tag in the slide. -remarks: '\[ [API set: PowerPointApi 1.3](/javascript/api/requirement-sets/powerpoint/powerpoint-api-requirement-sets) \]' +remarks: >- + \[ [API set: PowerPointApi 1.3](/javascript/api/requirement-sets/powerpoint/powerpoint-api-requirement-sets) \] + + + #### Examples + + + ```TypeScript + + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/tags/tags.yaml + + + await PowerPoint.run(async function (context) { + let presentationTags: PowerPoint.TagCollection = context.presentation.tags; + presentationTags.add("COLOR", "blue"); + + await context.sync(); + + const tag: PowerPoint.Tag = presentationTags.getItem("COLOR"); + tag.load("key, value"); + + await context.sync(); + + console.log("Added key " + JSON.stringify(tag.key) + " with value " + JSON.stringify(tag.value)); + }); + + ``` isPreview: false isDeprecated: false type: class diff --git a/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.tagcollection.yml b/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.tagcollection.yml index 81adc1217a..a454993603 100644 --- a/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.tagcollection.yml +++ b/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.tagcollection.yml @@ -23,12 +23,12 @@ remarks: >- // Decrement because the getSelectedSlideByIndex method is 1-based, // but the getItemAt method is 0-based. selectedSlideIndex = selectedSlideIndex - 1; - const slide = context.presentation.slides.getItemAt(selectedSlideIndex); + const slide: PowerPoint.Slide = context.presentation.slides.getItemAt(selectedSlideIndex); slide.tags.add("CUSTOMER_TYPE", "Premium"); await context.sync(); - const audienceTag = slide.tags.getItem("CUSTOMER_TYPE"); + const audienceTag: PowerPoint.Tag = slide.tags.getItem("CUSTOMER_TYPE"); audienceTag.load("key, value"); await context.sync(); @@ -89,7 +89,7 @@ methods: await PowerPoint.run(async function(context) { - const slide = context.presentation.slides.getItemAt(0); + const slide: PowerPoint.Slide = context.presentation.slides.getItemAt(0); slide.tags.add("OCEAN", "Indian"); slide.tags.add("PLANET", "Jupiter"); slide.tags.add("CONTINENT", "Antarctica"); @@ -141,7 +141,7 @@ methods: await PowerPoint.run(async function (context) { - let presentationTags = context.presentation.tags; + let presentationTags: PowerPoint.TagCollection = context.presentation.tags; presentationTags.delete("COLOR"); @@ -201,12 +201,12 @@ methods: // Decrement because the getSelectedSlideByIndex method is 1-based, // but the getItemAt method is 0-based. selectedSlideIndex = selectedSlideIndex - 1; - const slide = context.presentation.slides.getItemAt(selectedSlideIndex); + const slide: PowerPoint.Slide = context.presentation.slides.getItemAt(selectedSlideIndex); slide.tags.add("CUSTOMER_TYPE", "Premium"); await context.sync(); - const audienceTag = slide.tags.getItem("CUSTOMER_TYPE"); + const audienceTag: PowerPoint.Tag = slide.tags.getItem("CUSTOMER_TYPE"); audienceTag.load("key, value"); await context.sync(); diff --git a/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.textframe.yml b/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.textframe.yml index 8a707f6652..00c6de05b9 100644 --- a/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.textframe.yml +++ b/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.textframe.yml @@ -4,7 +4,49 @@ uid: 'powerpoint!PowerPoint.TextFrame:class' package: powerpoint! fullName: PowerPoint.TextFrame summary: Represents the text frame of a shape object. -remarks: '\[ [API set: PowerPointApi 1.4](/javascript/api/requirement-sets/powerpoint/powerpoint-api-requirement-sets) \]' +remarks: >- + \[ [API set: PowerPointApi 1.4](/javascript/api/requirement-sets/powerpoint/powerpoint-api-requirement-sets) \] + + + #### Examples + + + ```TypeScript + + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/text/get-set-textrange.yaml + + + // Selects the first 10 characters of the selected shape. + + await PowerPoint.run(async (context) => { + const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes(); + const shapeCount = shapes.getCount(); + await context.sync(); + if (shapeCount.value !== 1) { + console.warn("You must select only one shape with text in it."); + return; + } + const shape: PowerPoint.Shape = shapes.getItemAt(0); + const textFrame: PowerPoint.TextFrame = shape.textFrame.load("textRange,hasText"); + await context.sync(); + if (textFrame.hasText != true) { + console.warn("You must select only one shape with text in it."); + return; + } + const textRange: PowerPoint.TextRange = textFrame.textRange; + textRange.load("text"); + await context.sync(); + if (textRange.text.length < 10) { + console.warn("You must select only one shape with at least 10 characters in it."); + return; + } + const textRange10 = textRange.getSubstring(0, 10); + textRange10.setSelected(); + await context.sync(); + }); + + ``` isPreview: false isDeprecated: false type: class diff --git a/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.textrange.yml b/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.textrange.yml index a60dbe9a4c..06656144cd 100644 --- a/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.textrange.yml +++ b/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.textrange.yml @@ -20,7 +20,7 @@ remarks: >- // Sets the color of the selected text range to green. await PowerPoint.run(async (context) => { - const textRange = context.presentation.getSelectedTextRange(); + const textRange: PowerPoint.TextRange = context.presentation.getSelectedTextRange(); textRange.font.color = "green"; await context.sync(); }); @@ -65,7 +65,7 @@ properties: // Sets the color of the selected text range to green. await PowerPoint.run(async (context) => { - const textRange = context.presentation.getSelectedTextRange(); + const textRange: PowerPoint.TextRange = context.presentation.getSelectedTextRange(); textRange.font.color = "green"; await context.sync(); }); diff --git a/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.textverticalalignment.yml b/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.textverticalalignment.yml index ea4c7baef8..e9c780ca93 100644 --- a/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.textverticalalignment.yml +++ b/docs/docs-ref-autogen/powerpoint_1_4/powerpoint/powerpoint.textverticalalignment.yml @@ -31,8 +31,8 @@ remarks: >- // color, and centers it inside the braces. await PowerPoint.run(async (context) => { - const shapes = context.presentation.slides.getItemAt(0).shapes; - const braces = shapes.addGeometricShape(PowerPoint.GeometricShapeType.bracePair, { + 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, diff --git a/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.connectortype.yml b/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.connectortype.yml index 8a0a750565..7b30df9b51 100644 --- a/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.connectortype.yml +++ b/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.connectortype.yml @@ -24,11 +24,11 @@ remarks: >- // start and end points. Then it names the shape. await PowerPoint.run(async (context) => { - const shapes = context.presentation.slides.getItemAt(0).shapes; + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; // 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 = shapes.addLine(PowerPoint.ConnectorType.straight, + const line: PowerPoint.Shape = shapes.addLine(PowerPoint.ConnectorType.straight, { left: 400, top: 200, diff --git a/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.geometricshapetype.yml b/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.geometricshapetype.yml index b060114f7e..46f2a39913 100644 --- a/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.geometricshapetype.yml +++ b/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.geometricshapetype.yml @@ -24,14 +24,14 @@ remarks: >- // location and size. Then it names the shape. await PowerPoint.run(async (context) => { - const shapes = context.presentation.slides.getItemAt(0).shapes; - const hexagon = shapes.addGeometricShape(PowerPoint.GeometricShapeType.hexagon, - { - left: 100, - top: 100, - height: 150, - width: 150 - }); + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; + const shapeOptions: PowerPoint.ShapeAddOptions = { + left: 100, + top: 100, + height: 150, + width: 150 + }; + const hexagon: PowerPoint.Shape = shapes.addGeometricShape(PowerPoint.GeometricShapeType.hexagon, shapeOptions); hexagon.name = "Hexagon"; await context.sync(); diff --git a/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.insertslideformatting.yml b/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.insertslideformatting.yml index c23c7dca4d..e19936d98e 100644 --- a/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.insertslideformatting.yml +++ b/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.insertslideformatting.yml @@ -19,8 +19,8 @@ remarks: >- await PowerPoint.run(async function(context) { // Get the ID of the first selected slide. - const presentation = context.presentation; - const selected = presentation.getSelectedSlides().getItemAt(0); + const presentation: PowerPoint.Presentation = context.presentation; + const selected: PowerPoint.Slide = presentation.getSelectedSlides().getItemAt(0); selected.load("id"); await context.sync(); diff --git a/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.insertslideoptions.yml b/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.insertslideoptions.yml index 1f359cec9d..ea50dfea43 100644 --- a/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.insertslideoptions.yml +++ b/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.insertslideoptions.yml @@ -19,8 +19,8 @@ remarks: >- await PowerPoint.run(async function(context) { // Get the ID of the first selected slide. - const presentation = context.presentation; - const selected = presentation.getSelectedSlides().getItemAt(0); + const presentation: PowerPoint.Presentation = context.presentation; + const selected: PowerPoint.Slide = presentation.getSelectedSlides().getItemAt(0); selected.load("id"); await context.sync(); diff --git a/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.presentation.yml b/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.presentation.yml index e56b33b212..81bee9fa31 100644 --- a/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.presentation.yml +++ b/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.presentation.yml @@ -19,8 +19,8 @@ remarks: >- await PowerPoint.run(async function(context) { // Get the ID of the first selected slide. - const presentation = context.presentation; - const selected = presentation.getSelectedSlides().getItemAt(0); + const presentation: PowerPoint.Presentation = context.presentation; + const selected: PowerPoint.Slide = presentation.getSelectedSlides().getItemAt(0); selected.load("id"); await context.sync(); @@ -136,7 +136,7 @@ methods: // Arranges the selected shapes in a line from left to right. await PowerPoint.run(async (context) => { - const shapes = context.presentation.getSelectedShapes(); + const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes(); const shapeCount = shapes.getCount(); shapes.load("items"); await context.sync(); @@ -164,7 +164,7 @@ methods: await PowerPoint.run(async (context) => { let finalTable = ""; - const shapes = context.presentation.getSelectedShapes(); + const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes(); const shapeCount = shapes.getCount(); await context.sync(); finalTable += "
getSelectedShapes.getCount returned:" + shapeCount.value + "
"; @@ -189,7 +189,7 @@ methods: await PowerPoint.run(async (context) => { context.presentation.load("slides"); await context.sync(); - const slides = context.presentation.getSelectedSlides(); + const slides: PowerPoint.SlideScopedCollection = context.presentation.getSelectedSlides(); const slideCount = slides.getCount(); slides.load("items"); await context.sync(); @@ -197,7 +197,7 @@ methods: slides.items.map((slide) => { savedSlideSelection.push(slide.id); }); - const shapes = context.presentation.getSelectedShapes(); + const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes(); const shapeCount = shapes.getCount(); shapes.load("items"); await context.sync(); @@ -244,7 +244,7 @@ methods: const allSlidesCount = context.presentation.slides.getCount(); context.presentation.slides.load("items"); await context.sync(); - let allSlideItems = context.presentation.slides.items; + let allSlideItems: PowerPoint.Slide[] = context.presentation.slides.items; allSlideItems.map((slide, index) => { allSlidesList[slide.id] = `Slide ${index + 1}`; }); @@ -252,7 +252,7 @@ methods: if ($("#id-check-usenative").is(":checked")) { context.presentation.load("tags"); } - const slides = context.presentation.getSelectedSlides(); + const slides: PowerPoint.SlideScopedCollection = context.presentation.getSelectedSlides(); const slideCount = slides.getCount(); slides.load("items"); await context.sync(); @@ -277,7 +277,7 @@ methods: let finalTable = ""; context.presentation.load("slides"); await context.sync(); - const slides = context.presentation.getSelectedSlides(); + const slides: PowerPoint.SlideScopedCollection = context.presentation.getSelectedSlides(); const slideCount = slides.getCount(); await context.sync(); finalTable += "
getSelectedSlides.getCount returned:" + slideCount.value + "
"; @@ -326,7 +326,7 @@ methods: // Gets the selected text range and prints data about the range on the task pane. await PowerPoint.run(async (context) => { - const textRange = context.presentation.getSelectedTextRange(); + const textRange: PowerPoint.TextRange = context.presentation.getSelectedTextRange(); try { await context.sync(); } catch (error) { @@ -365,9 +365,9 @@ methods: // Sets the range selection to the range that was saved previously. await PowerPoint.run(async (context) => { - const slide1 = context.presentation.slides.getItem(savedTextSlideSelection[0]); - const shape1 = slide1.shapes.getItem(savedTextShapeSelection[0]); - const textRange = shape1.textFrame.textRange.getSubstring(savedTextTextRangeStart, savedTextTextRangeLength); + 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); textRange.setSelected(); await context.sync(); }); @@ -415,8 +415,8 @@ methods: await PowerPoint.run(async function(context) { // Get the ID of the first selected slide. - const presentation = context.presentation; - const selected = presentation.getSelectedSlides().getItemAt(0); + const presentation: PowerPoint.Presentation = context.presentation; + const selected: PowerPoint.Slide = presentation.getSelectedSlides().getItemAt(0); selected.load("id"); await context.sync(); @@ -549,9 +549,9 @@ methods: await PowerPoint.run(async (context) => { context.presentation.load("slides"); await context.sync(); - const slide2 = context.presentation.slides.getItemAt(1); - const slide4 = context.presentation.slides.getItemAt(3); - const slide5 = context.presentation.slides.getItemAt(4); + const slide2: PowerPoint.Slide = context.presentation.slides.getItemAt(1); + const slide4: PowerPoint.Slide = context.presentation.slides.getItemAt(3); + const slide5: PowerPoint.Slide = context.presentation.slides.getItemAt(4); slide2.load("id"); slide4.load("id"); slide5.load("id"); diff --git a/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.shape.yml b/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.shape.yml index a98a805060..39c1be205b 100644 --- a/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.shape.yml +++ b/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.shape.yml @@ -21,7 +21,7 @@ remarks: >- await PowerPoint.run(async (context) => { // Get the type of shape for every shape in the collection. - const shapes = context.presentation.slides.getItemAt(0).shapes; + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; shapes.load("type"); await context.sync(); @@ -74,7 +74,7 @@ properties: // Changes the selected shapes fill color to red. await PowerPoint.run(async (context) => { - const shapes = context.presentation.getSelectedShapes(); + const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes(); const shapeCount = shapes.getCount(); shapes.load("items"); await context.sync(); @@ -114,7 +114,7 @@ properties: // Arranges the selected shapes in a line from left to right. await PowerPoint.run(async (context) => { - const shapes = context.presentation.getSelectedShapes(); + const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes(); const shapeCount = shapes.getCount(); shapes.load("items"); await context.sync(); @@ -174,7 +174,7 @@ properties: // Arranges the selected shapes in a line from left to right. await PowerPoint.run(async (context) => { - const shapes = context.presentation.getSelectedShapes(); + const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes(); const shapeCount = shapes.getCount(); shapes.load("items"); await context.sync(); @@ -270,7 +270,7 @@ properties: // Arranges the selected shapes in a line from left to right. await PowerPoint.run(async (context) => { - const shapes = context.presentation.getSelectedShapes(); + const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes(); const shapeCount = shapes.getCount(); shapes.load("items"); await context.sync(); @@ -319,7 +319,7 @@ properties: await PowerPoint.run(async (context) => { // Get the type of shape for every shape in the collection. - const shapes = context.presentation.slides.getItemAt(0).shapes; + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; shapes.load("type"); await context.sync(); @@ -364,7 +364,7 @@ properties: // Arranges the selected shapes in a line from left to right. await PowerPoint.run(async (context) => { - const shapes = context.presentation.getSelectedShapes(); + const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes(); const shapeCount = shapes.getCount(); shapes.load("items"); await context.sync(); @@ -397,7 +397,38 @@ methods: package: powerpoint! fullName: delete() summary: Deletes the shape from the shape collection. Does nothing if the shape does not exist. - remarks: '\[ [API set: PowerPointApi 1.3](/javascript/api/requirement-sets/powerpoint/powerpoint-api-requirement-sets) \]' + remarks: >- + \[ [API set: PowerPointApi 1.3](/javascript/api/requirement-sets/powerpoint/powerpoint-api-requirement-sets) \] + + + #### Examples + + + ```TypeScript + + // 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 then iterates through them, deleting each one. + + await PowerPoint.run(async (context) => { + const slide: PowerPoint.Slide = context.presentation.slides.getItemAt(0); + const shapes: PowerPoint.ShapeCollection = slide.shapes; + + // Load all the shapes in the collection without loading their properties. + shapes.load("items/$none"); + + await context.sync(); + + shapes.items.forEach((shape) => shape.delete()); + + await context.sync(); + }); + + ``` isPreview: false isDeprecated: false syntax: diff --git a/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.shapeaddoptions.yml b/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.shapeaddoptions.yml index 241f97b00f..d492e51cf7 100644 --- a/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.shapeaddoptions.yml +++ b/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.shapeaddoptions.yml @@ -4,7 +4,40 @@ uid: 'powerpoint!PowerPoint.ShapeAddOptions:interface' package: powerpoint! fullName: PowerPoint.ShapeAddOptions summary: Represents the available options when adding shapes. -remarks: '\[ [API set: PowerPointApi 1.4](/javascript/api/requirement-sets/powerpoint/powerpoint-api-requirement-sets) \]' +remarks: >- + \[ [API set: PowerPointApi 1.4](/javascript/api/requirement-sets/powerpoint/powerpoint-api-requirement-sets) \] + + + #### Examples + + + ```TypeScript + + // 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 hexagon shape to the collection, while specifying its + + // location and size. Then it names the shape. + + await PowerPoint.run(async (context) => { + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; + const shapeOptions: PowerPoint.ShapeAddOptions = { + left: 100, + top: 100, + height: 150, + width: 150 + }; + const hexagon: PowerPoint.Shape = shapes.addGeometricShape(PowerPoint.GeometricShapeType.hexagon, shapeOptions); + hexagon.name = "Hexagon"; + + await context.sync(); + }); + + ``` isPreview: false isDeprecated: false type: interface diff --git a/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.shapecollection.yml b/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.shapecollection.yml index 8931536b96..a5efe8e5ec 100644 --- a/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.shapecollection.yml +++ b/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.shapecollection.yml @@ -21,7 +21,7 @@ remarks: >- await PowerPoint.run(async (context) => { // Get the type of shape for every shape in the collection. - const shapes = context.presentation.slides.getItemAt(0).shapes; + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; shapes.load("type"); await context.sync(); @@ -91,14 +91,14 @@ methods: // location and size. Then it names the shape. await PowerPoint.run(async (context) => { - const shapes = context.presentation.slides.getItemAt(0).shapes; - const hexagon = shapes.addGeometricShape(PowerPoint.GeometricShapeType.hexagon, - { - left: 100, - top: 100, - height: 150, - width: 150 - }); + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; + const shapeOptions: PowerPoint.ShapeAddOptions = { + left: 100, + top: 100, + height: 150, + width: 150 + }; + const hexagon: PowerPoint.Shape = shapes.addGeometricShape(PowerPoint.GeometricShapeType.hexagon, shapeOptions); hexagon.name = "Hexagon"; await context.sync(); @@ -232,11 +232,11 @@ methods: // start and end points. Then it names the shape. await PowerPoint.run(async (context) => { - const shapes = context.presentation.slides.getItemAt(0).shapes; + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; // 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 = shapes.addLine(PowerPoint.ConnectorType.straight, + const line: PowerPoint.Shape = shapes.addLine(PowerPoint.ConnectorType.straight, { left: 400, top: 200, @@ -320,8 +320,8 @@ methods: // location, and size. Then it names the text box. await PowerPoint.run(async (context) => { - const shapes = context.presentation.slides.getItemAt(0).shapes; - const textbox = shapes.addTextBox("Hello!", + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; + const textbox: PowerPoint.Shape = shapes.addTextBox("Hello!", { left: 100, top: 300, @@ -397,13 +397,13 @@ methods: await PowerPoint.run(async function(context) { - const slide = context.presentation.slides.getItemAt(0); - const shape = slide.shapes.getItemAt(0); + const slide: PowerPoint.Slide = context.presentation.slides.getItemAt(0); + const shape: PowerPoint.Shape = slide.shapes.getItemAt(0); shape.tags.add("MOUNTAIN", "Denali"); await context.sync(); - const myShapeTag = shape.tags.getItem("MOUNTAIN"); + const myShapeTag: PowerPoint.Tag = shape.tags.getItem("MOUNTAIN"); myShapeTag.load("key, value"); await context.sync(); @@ -501,7 +501,7 @@ methods: await PowerPoint.run(async (context) => { // Get the type of shape for every shape in the collection. - const shapes = context.presentation.slides.getItemAt(0).shapes; + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; shapes.load("type"); await context.sync(); diff --git a/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.shapefill.yml b/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.shapefill.yml index bf9d6a34aa..923dd0585d 100644 --- a/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.shapefill.yml +++ b/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.shapefill.yml @@ -21,7 +21,7 @@ remarks: >- await PowerPoint.run(async (context) => { // Get the type of shape for every shape in the collection. - const shapes = context.presentation.slides.getItemAt(0).shapes; + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; shapes.load("type"); await context.sync(); @@ -60,7 +60,42 @@ properties: summary: >- 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"). - remarks: '\[ [API set: PowerPointApi 1.4](/javascript/api/requirement-sets/powerpoint/powerpoint-api-requirement-sets) \]' + remarks: >- + \[ [API set: PowerPointApi 1.4](/javascript/api/requirement-sets/powerpoint/powerpoint-api-requirement-sets) \] + + + #### Examples + + + ```TypeScript + + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/get-set-shapes.yaml + + + // Creates random shapes on the selected slide. + + await PowerPoint.run(async (context) => { + let finalTable = ""; + const currentSlide: PowerPoint.Slide = context.presentation.getSelectedSlides().getItemAt(0); + const maxNewShapeWidth = 200; + const maxNewShapeHeight = 200; + const minNewShapeWidth = 50; + const minNewShapeHeight = 50; + for (let i = 0; i < 20; i++) { + const rectangle: PowerPoint.Shape = currentSlide.shapes.addGeometricShape(PowerPoint.GeometricShapeType.rectangle); + rectangle.height = getRandomBetween(minNewShapeWidth, maxNewShapeWidth); + rectangle.width = getRandomBetween(minNewShapeHeight, maxNewShapeHeight); + rectangle.left = getRandomBetween(0, slideWidth - rectangle.width); + rectangle.top = getRandomBetween(0, slideHeight - rectangle.height); + rectangle.fill.foregroundColor = generateRandomHexColor(); + } + finalTable += "Done
"; + $("#slide-tags").empty(); + $("#slide-tags").append(finalTable); + }); + + ``` isPreview: false isDeprecated: false syntax: @@ -92,7 +127,7 @@ properties: await PowerPoint.run(async (context) => { // Get the type of shape for every shape in the collection. - const shapes = context.presentation.slides.getItemAt(0).shapes; + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; shapes.load("type"); await context.sync(); @@ -232,7 +267,7 @@ methods: // Changes the selected shapes fill color to red. await PowerPoint.run(async (context) => { - const shapes = context.presentation.getSelectedShapes(); + const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes(); const shapeCount = shapes.getCount(); shapes.load("items"); await context.sync(); diff --git a/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.shapefont.yml b/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.shapefont.yml index f74d0f3e9a..1445929e14 100644 --- a/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.shapefont.yml +++ b/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.shapefont.yml @@ -20,7 +20,7 @@ remarks: >- // Sets the color of the selected text range to green. await PowerPoint.run(async (context) => { - const textRange = context.presentation.getSelectedTextRange(); + const textRange: PowerPoint.TextRange = context.presentation.getSelectedTextRange(); textRange.font.color = "green"; await context.sync(); }); @@ -67,7 +67,7 @@ properties: // Sets the color of the selected text range to green. await PowerPoint.run(async (context) => { - const textRange = context.presentation.getSelectedTextRange(); + const textRange: PowerPoint.TextRange = context.presentation.getSelectedTextRange(); textRange.font.color = "green"; await context.sync(); }); diff --git a/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.shapelinedashstyle.yml b/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.shapelinedashstyle.yml index 7d6be56a1f..d45033c2f5 100644 --- a/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.shapelinedashstyle.yml +++ b/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.shapelinedashstyle.yml @@ -21,7 +21,7 @@ remarks: >- await PowerPoint.run(async (context) => { // Get the type of shape for every shape in the collection. - const shapes = context.presentation.slides.getItemAt(0).shapes; + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; shapes.load("type"); await context.sync(); diff --git a/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.shapelineformat.yml b/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.shapelineformat.yml index 813e163050..1c689d7ca6 100644 --- a/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.shapelineformat.yml +++ b/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.shapelineformat.yml @@ -23,7 +23,7 @@ remarks: >- await PowerPoint.run(async (context) => { // Get the type of shape for every shape in the collection. - const shapes = context.presentation.slides.getItemAt(0).shapes; + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; shapes.load("type"); await context.sync(); @@ -93,7 +93,7 @@ properties: await PowerPoint.run(async (context) => { // Get the type of shape for every shape in the collection. - const shapes = context.presentation.slides.getItemAt(0).shapes; + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; shapes.load("type"); await context.sync(); diff --git a/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.shapescopedcollection.yml b/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.shapescopedcollection.yml index c32d8f5d3f..e3ac63938e 100644 --- a/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.shapescopedcollection.yml +++ b/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.shapescopedcollection.yml @@ -4,7 +4,33 @@ uid: 'powerpoint!PowerPoint.ShapeScopedCollection:class' package: powerpoint! fullName: PowerPoint.ShapeScopedCollection summary: Represents a collection of shapes. -remarks: '\[ [API set: PowerPointApi 1.5](/javascript/api/requirement-sets/powerpoint/powerpoint-api-requirement-sets) \]' +remarks: >- + \[ [API set: PowerPointApi 1.5](/javascript/api/requirement-sets/powerpoint/powerpoint-api-requirement-sets) \] + + + #### Examples + + + ```TypeScript + + // 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"); + await context.sync(); + shapes.items.map((shape) => { + shape.fill.setSolidColor("red"); + }); + await context.sync(); + }); + + ``` isPreview: false isDeprecated: false type: class @@ -41,7 +67,40 @@ methods: package: powerpoint! fullName: getCount() summary: Gets the number of shapes in the collection. - remarks: '\[ [API set: PowerPointApi 1.5](/javascript/api/requirement-sets/powerpoint/powerpoint-api-requirement-sets) \]' + remarks: >- + \[ [API set: PowerPointApi 1.5](/javascript/api/requirement-sets/powerpoint/powerpoint-api-requirement-sets) \] + + + #### Examples + + + ```TypeScript + + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/get-set-shapes.yaml + + + // Gets the shapes you selected on the slide and displays their IDs on the task pane. + + await PowerPoint.run(async (context) => { + let finalTable = ""; + const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes(); + const shapeCount = shapes.getCount(); + await context.sync(); + finalTable += "
getSelectedShapes.getCount returned:" + shapeCount.value + "
"; + finalTable += + "
"; + shapes.load("items"); + await context.sync(); + shapes.items.map((shape, index) => { + finalTable += ""; + }); + finalTable += "
IndexId
" + index + "" + shape.id + "
"; + $("#outputSpan").empty(); + $("#outputSpan").append(finalTable); + }); + + ``` isPreview: false isDeprecated: false syntax: diff --git a/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.shapetype.yml b/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.shapetype.yml index aed58db05c..c594c61330 100644 --- a/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.shapetype.yml +++ b/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.shapetype.yml @@ -21,7 +21,7 @@ remarks: >- await PowerPoint.run(async (context) => { // Get the type of shape for every shape in the collection. - const shapes = context.presentation.slides.getItemAt(0).shapes; + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; shapes.load("type"); await context.sync(); diff --git a/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.slide.yml b/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.slide.yml index e9ecf795aa..1beaacb5a2 100644 --- a/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.slide.yml +++ b/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.slide.yml @@ -20,7 +20,7 @@ remarks: >- // Reselects shapes that were saved previously. await PowerPoint.run(async (context) => { - const slide1 = context.presentation.slides.getItem(savedSlideSelection[0]); + const slide1: PowerPoint.Slide = context.presentation.slides.getItem(savedSlideSelection[0]); await context.sync(); slide1.setSelectedShapes(savedShapeSelection); await context.sync(); @@ -129,7 +129,7 @@ methods: await PowerPoint.run(async (context) => { context.presentation.load("slides"); await context.sync(); - const slides = context.presentation.getSelectedSlides(); + const slides: PowerPoint.SlideScopedCollection = context.presentation.getSelectedSlides(); const slideCount = slides.getCount(); slides.load("items"); await context.sync(); @@ -234,7 +234,7 @@ methods: // Reselects shapes that were saved previously. await PowerPoint.run(async (context) => { - const slide1 = context.presentation.slides.getItem(savedSlideSelection[0]); + const slide1: PowerPoint.Slide = context.presentation.slides.getItem(savedSlideSelection[0]); await context.sync(); slide1.setSelectedShapes(savedShapeSelection); await context.sync(); @@ -252,9 +252,9 @@ methods: const slide1 = context.presentation.slides.getItemAt(0); slide1.load("shapes"); await context.sync(); - const shapes = slide1.shapes; - const shape1 = shapes.getItemAt(0); - const shape2 = shapes.getItemAt(1); + const shapes: PowerPoint.ShapeCollection = slide1.shapes; + const shape1: PowerPoint.Shape = shapes.getItemAt(0); + const shape2: PowerPoint.Shape = shapes.getItemAt(1); shape1.load("id"); shape2.load("id"); await context.sync(); diff --git a/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.slidecollection.yml b/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.slidecollection.yml index a59d072763..5b5589f95c 100644 --- a/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.slidecollection.yml +++ b/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.slidecollection.yml @@ -164,9 +164,9 @@ methods: await PowerPoint.run(async (context) => { context.presentation.load("slides"); await context.sync(); - const slide2 = context.presentation.slides.getItemAt(1); - const slide4 = context.presentation.slides.getItemAt(3); - const slide5 = context.presentation.slides.getItemAt(4); + const slide2: PowerPoint.Slide = context.presentation.slides.getItemAt(1); + const slide4: PowerPoint.Slide = context.presentation.slides.getItemAt(3); + const slide5: PowerPoint.Slide = context.presentation.slides.getItemAt(4); slide2.load("id"); slide4.load("id"); slide5.load("id"); diff --git a/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.slidelayout.yml b/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.slidelayout.yml index 1a3058a086..6ad7e506f4 100644 --- a/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.slidelayout.yml +++ b/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.slidelayout.yml @@ -19,7 +19,7 @@ remarks: >- await PowerPoint.run(async function(context) { // Load information about all the slide masters and associated layouts. - const slideMasters = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); + const slideMasters: PowerPoint.SlideMasterCollection = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); await context.sync(); // Log the name and ID of each slide master. @@ -28,7 +28,7 @@ remarks: >- console.log("Master ID: " + slideMasters.items[i].id); // Log the name and ID of each slide layout in the slide master. - const layoutsInMaster = slideMasters.items[i].layouts; + const layoutsInMaster: PowerPoint.SlideLayoutCollection = slideMasters.items[i].layouts; for (let j = 0; j < layoutsInMaster.items.length; j++) { console.log(" Layout name: " + layoutsInMaster.items[j].name + " Layout ID: " + layoutsInMaster.items[j].id); } @@ -74,7 +74,7 @@ properties: await PowerPoint.run(async function(context) { // Load information about all the slide masters and associated layouts. - const slideMasters = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); + const slideMasters: PowerPoint.SlideMasterCollection = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); await context.sync(); // Log the name and ID of each slide master. @@ -83,7 +83,7 @@ properties: console.log("Master ID: " + slideMasters.items[i].id); // Log the name and ID of each slide layout in the slide master. - const layoutsInMaster = slideMasters.items[i].layouts; + const layoutsInMaster: PowerPoint.SlideLayoutCollection = slideMasters.items[i].layouts; for (let j = 0; j < layoutsInMaster.items.length; j++) { console.log(" Layout name: " + layoutsInMaster.items[j].name + " Layout ID: " + layoutsInMaster.items[j].id); } diff --git a/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.slidelayoutcollection.yml b/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.slidelayoutcollection.yml index b67d17fba0..7076f35327 100644 --- a/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.slidelayoutcollection.yml +++ b/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.slidelayoutcollection.yml @@ -19,7 +19,7 @@ remarks: >- await PowerPoint.run(async function(context) { // Load information about all the slide masters and associated layouts. - const slideMasters = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); + const slideMasters: PowerPoint.SlideMasterCollection = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); await context.sync(); // Log the name and ID of each slide master. @@ -28,7 +28,7 @@ remarks: >- console.log("Master ID: " + slideMasters.items[i].id); // Log the name and ID of each slide layout in the slide master. - const layoutsInMaster = slideMasters.items[i].layouts; + const layoutsInMaster: PowerPoint.SlideLayoutCollection = slideMasters.items[i].layouts; for (let j = 0; j < layoutsInMaster.items.length; j++) { console.log(" Layout name: " + layoutsInMaster.items[j].name + " Layout ID: " + layoutsInMaster.items[j].id); } @@ -190,7 +190,7 @@ methods: await PowerPoint.run(async function(context) { // Load information about all the slide masters and associated layouts. - const slideMasters = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); + const slideMasters: PowerPoint.SlideMasterCollection = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); await context.sync(); // Log the name and ID of each slide master. @@ -199,7 +199,7 @@ methods: console.log("Master ID: " + slideMasters.items[i].id); // Log the name and ID of each slide layout in the slide master. - const layoutsInMaster = slideMasters.items[i].layouts; + const layoutsInMaster: PowerPoint.SlideLayoutCollection = slideMasters.items[i].layouts; for (let j = 0; j < layoutsInMaster.items.length; j++) { console.log(" Layout name: " + layoutsInMaster.items[j].name + " Layout ID: " + layoutsInMaster.items[j].id); } diff --git a/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.slidemaster.yml b/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.slidemaster.yml index 5f8c223a24..400340ed76 100644 --- a/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.slidemaster.yml +++ b/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.slidemaster.yml @@ -19,7 +19,7 @@ remarks: >- await PowerPoint.run(async function(context) { // Load information about all the slide masters and associated layouts. - const slideMasters = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); + const slideMasters: PowerPoint.SlideMasterCollection = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); await context.sync(); // Log the name and ID of each slide master. @@ -28,7 +28,7 @@ remarks: >- console.log("Master ID: " + slideMasters.items[i].id); // Log the name and ID of each slide layout in the slide master. - const layoutsInMaster = slideMasters.items[i].layouts; + const layoutsInMaster: PowerPoint.SlideLayoutCollection = slideMasters.items[i].layouts; for (let j = 0; j < layoutsInMaster.items.length; j++) { console.log(" Layout name: " + layoutsInMaster.items[j].name + " Layout ID: " + layoutsInMaster.items[j].id); } @@ -74,7 +74,7 @@ properties: await PowerPoint.run(async function(context) { // Load information about all the slide masters and associated layouts. - const slideMasters = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); + const slideMasters: PowerPoint.SlideMasterCollection = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); await context.sync(); // Log the name and ID of each slide master. @@ -83,7 +83,7 @@ properties: console.log("Master ID: " + slideMasters.items[i].id); // Log the name and ID of each slide layout in the slide master. - const layoutsInMaster = slideMasters.items[i].layouts; + const layoutsInMaster: PowerPoint.SlideLayoutCollection = slideMasters.items[i].layouts; for (let j = 0; j < layoutsInMaster.items.length; j++) { console.log(" Layout name: " + layoutsInMaster.items[j].name + " Layout ID: " + layoutsInMaster.items[j].id); } diff --git a/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.slidemastercollection.yml b/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.slidemastercollection.yml index 8f3aef0c34..f3022d8d5b 100644 --- a/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.slidemastercollection.yml +++ b/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.slidemastercollection.yml @@ -19,7 +19,7 @@ remarks: >- await PowerPoint.run(async function(context) { // Load information about all the slide masters and associated layouts. - const slideMasters = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); + const slideMasters: PowerPoint.SlideMasterCollection = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); await context.sync(); // Log the name and ID of each slide master. @@ -28,7 +28,7 @@ remarks: >- console.log("Master ID: " + slideMasters.items[i].id); // Log the name and ID of each slide layout in the slide master. - const layoutsInMaster = slideMasters.items[i].layouts; + const layoutsInMaster: PowerPoint.SlideLayoutCollection = slideMasters.items[i].layouts; for (let j = 0; j < layoutsInMaster.items.length; j++) { console.log(" Layout name: " + layoutsInMaster.items[j].name + " Layout ID: " + layoutsInMaster.items[j].id); } @@ -190,7 +190,7 @@ methods: await PowerPoint.run(async function(context) { // Load information about all the slide masters and associated layouts. - const slideMasters = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); + const slideMasters: PowerPoint.SlideMasterCollection = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); await context.sync(); // Log the name and ID of each slide master. @@ -199,7 +199,7 @@ methods: console.log("Master ID: " + slideMasters.items[i].id); // Log the name and ID of each slide layout in the slide master. - const layoutsInMaster = slideMasters.items[i].layouts; + const layoutsInMaster: PowerPoint.SlideLayoutCollection = slideMasters.items[i].layouts; for (let j = 0; j < layoutsInMaster.items.length; j++) { console.log(" Layout name: " + layoutsInMaster.items[j].name + " Layout ID: " + layoutsInMaster.items[j].id); } diff --git a/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.slidescopedcollection.yml b/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.slidescopedcollection.yml index 9215cb0ed3..a4f4400712 100644 --- a/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.slidescopedcollection.yml +++ b/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.slidescopedcollection.yml @@ -4,7 +4,42 @@ uid: 'powerpoint!PowerPoint.SlideScopedCollection:class' package: powerpoint! fullName: PowerPoint.SlideScopedCollection summary: Represents a collection of slides in the presentation. -remarks: '\[ [API set: PowerPointApi 1.5](/javascript/api/requirement-sets/powerpoint/powerpoint-api-requirement-sets) \]' +remarks: >- + \[ [API set: PowerPointApi 1.5](/javascript/api/requirement-sets/powerpoint/powerpoint-api-requirement-sets) \] + + + #### Examples + + + ```TypeScript + + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/get-set-shapes.yaml + + + // Saves which shapes are selected so that they can be reselected later. + + await PowerPoint.run(async (context) => { + context.presentation.load("slides"); + await context.sync(); + const slides: PowerPoint.SlideScopedCollection = context.presentation.getSelectedSlides(); + const slideCount = slides.getCount(); + slides.load("items"); + await context.sync(); + savedSlideSelection = []; + slides.items.map((slide) => { + savedSlideSelection.push(slide.id); + }); + const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes(); + const shapeCount = shapes.getCount(); + shapes.load("items"); + await context.sync(); + shapes.items.map((shape) => { + savedShapeSelection.push(shape.id); + }); + }); + + ``` isPreview: false isDeprecated: false type: class diff --git a/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.tag.yml b/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.tag.yml index b1fb1165ab..58489cace5 100644 --- a/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.tag.yml +++ b/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.tag.yml @@ -4,7 +4,34 @@ uid: 'powerpoint!PowerPoint.Tag:class' package: powerpoint! fullName: PowerPoint.Tag summary: Represents a single tag in the slide. -remarks: '\[ [API set: PowerPointApi 1.3](/javascript/api/requirement-sets/powerpoint/powerpoint-api-requirement-sets) \]' +remarks: >- + \[ [API set: PowerPointApi 1.3](/javascript/api/requirement-sets/powerpoint/powerpoint-api-requirement-sets) \] + + + #### Examples + + + ```TypeScript + + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/tags/tags.yaml + + + await PowerPoint.run(async function (context) { + let presentationTags: PowerPoint.TagCollection = context.presentation.tags; + presentationTags.add("COLOR", "blue"); + + await context.sync(); + + const tag: PowerPoint.Tag = presentationTags.getItem("COLOR"); + tag.load("key, value"); + + await context.sync(); + + console.log("Added key " + JSON.stringify(tag.key) + " with value " + JSON.stringify(tag.value)); + }); + + ``` isPreview: false isDeprecated: false type: class diff --git a/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.tagcollection.yml b/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.tagcollection.yml index 81adc1217a..a454993603 100644 --- a/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.tagcollection.yml +++ b/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.tagcollection.yml @@ -23,12 +23,12 @@ remarks: >- // Decrement because the getSelectedSlideByIndex method is 1-based, // but the getItemAt method is 0-based. selectedSlideIndex = selectedSlideIndex - 1; - const slide = context.presentation.slides.getItemAt(selectedSlideIndex); + const slide: PowerPoint.Slide = context.presentation.slides.getItemAt(selectedSlideIndex); slide.tags.add("CUSTOMER_TYPE", "Premium"); await context.sync(); - const audienceTag = slide.tags.getItem("CUSTOMER_TYPE"); + const audienceTag: PowerPoint.Tag = slide.tags.getItem("CUSTOMER_TYPE"); audienceTag.load("key, value"); await context.sync(); @@ -89,7 +89,7 @@ methods: await PowerPoint.run(async function(context) { - const slide = context.presentation.slides.getItemAt(0); + const slide: PowerPoint.Slide = context.presentation.slides.getItemAt(0); slide.tags.add("OCEAN", "Indian"); slide.tags.add("PLANET", "Jupiter"); slide.tags.add("CONTINENT", "Antarctica"); @@ -141,7 +141,7 @@ methods: await PowerPoint.run(async function (context) { - let presentationTags = context.presentation.tags; + let presentationTags: PowerPoint.TagCollection = context.presentation.tags; presentationTags.delete("COLOR"); @@ -201,12 +201,12 @@ methods: // Decrement because the getSelectedSlideByIndex method is 1-based, // but the getItemAt method is 0-based. selectedSlideIndex = selectedSlideIndex - 1; - const slide = context.presentation.slides.getItemAt(selectedSlideIndex); + const slide: PowerPoint.Slide = context.presentation.slides.getItemAt(selectedSlideIndex); slide.tags.add("CUSTOMER_TYPE", "Premium"); await context.sync(); - const audienceTag = slide.tags.getItem("CUSTOMER_TYPE"); + const audienceTag: PowerPoint.Tag = slide.tags.getItem("CUSTOMER_TYPE"); audienceTag.load("key, value"); await context.sync(); diff --git a/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.textframe.yml b/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.textframe.yml index 013eb8fd79..6d2e0188c3 100644 --- a/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.textframe.yml +++ b/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.textframe.yml @@ -4,7 +4,49 @@ uid: 'powerpoint!PowerPoint.TextFrame:class' package: powerpoint! fullName: PowerPoint.TextFrame summary: Represents the text frame of a shape object. -remarks: '\[ [API set: PowerPointApi 1.4](/javascript/api/requirement-sets/powerpoint/powerpoint-api-requirement-sets) \]' +remarks: >- + \[ [API set: PowerPointApi 1.4](/javascript/api/requirement-sets/powerpoint/powerpoint-api-requirement-sets) \] + + + #### Examples + + + ```TypeScript + + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/text/get-set-textrange.yaml + + + // Selects the first 10 characters of the selected shape. + + await PowerPoint.run(async (context) => { + const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes(); + const shapeCount = shapes.getCount(); + await context.sync(); + if (shapeCount.value !== 1) { + console.warn("You must select only one shape with text in it."); + return; + } + const shape: PowerPoint.Shape = shapes.getItemAt(0); + const textFrame: PowerPoint.TextFrame = shape.textFrame.load("textRange,hasText"); + await context.sync(); + if (textFrame.hasText != true) { + console.warn("You must select only one shape with text in it."); + return; + } + const textRange: PowerPoint.TextRange = textFrame.textRange; + textRange.load("text"); + await context.sync(); + if (textRange.text.length < 10) { + console.warn("You must select only one shape with at least 10 characters in it."); + return; + } + const textRange10 = textRange.getSubstring(0, 10); + textRange10.setSelected(); + await context.sync(); + }); + + ``` isPreview: false isDeprecated: false type: class diff --git a/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.textrange.yml b/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.textrange.yml index 819a5bb4d6..4e10393b79 100644 --- a/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.textrange.yml +++ b/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.textrange.yml @@ -20,7 +20,7 @@ remarks: >- // Sets the color of the selected text range to green. await PowerPoint.run(async (context) => { - const textRange = context.presentation.getSelectedTextRange(); + const textRange: PowerPoint.TextRange = context.presentation.getSelectedTextRange(); textRange.font.color = "green"; await context.sync(); }); @@ -65,7 +65,7 @@ properties: // Sets the color of the selected text range to green. await PowerPoint.run(async (context) => { - const textRange = context.presentation.getSelectedTextRange(); + const textRange: PowerPoint.TextRange = context.presentation.getSelectedTextRange(); textRange.font.color = "green"; await context.sync(); }); @@ -259,21 +259,21 @@ methods: // Selects the first 10 characters of the selected shape. await PowerPoint.run(async (context) => { - const shapes = context.presentation.getSelectedShapes(); + const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes(); const shapeCount = shapes.getCount(); await context.sync(); if (shapeCount.value !== 1) { console.warn("You must select only one shape with text in it."); return; } - const shape = shapes.getItemAt(0); - const textFrame = shape.textFrame.load("textRange,hasText"); + const shape: PowerPoint.Shape = shapes.getItemAt(0); + const textFrame: PowerPoint.TextFrame = shape.textFrame.load("textRange,hasText"); await context.sync(); if (textFrame.hasText != true) { console.warn("You must select only one shape with text in it."); return; } - const textRange = textFrame.textRange; + const textRange: PowerPoint.TextRange = textFrame.textRange; textRange.load("text"); await context.sync(); if (textRange.text.length < 10) { @@ -292,9 +292,9 @@ methods: // Sets the range selection to the range that was saved previously. await PowerPoint.run(async (context) => { - const slide1 = context.presentation.slides.getItem(savedTextSlideSelection[0]); - const shape1 = slide1.shapes.getItem(savedTextShapeSelection[0]); - const textRange = shape1.textFrame.textRange.getSubstring(savedTextTextRangeStart, savedTextTextRangeLength); + 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); textRange.setSelected(); await context.sync(); }); diff --git a/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.textverticalalignment.yml b/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.textverticalalignment.yml index ea4c7baef8..e9c780ca93 100644 --- a/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.textverticalalignment.yml +++ b/docs/docs-ref-autogen/powerpoint_1_5/powerpoint/powerpoint.textverticalalignment.yml @@ -31,8 +31,8 @@ remarks: >- // color, and centers it inside the braces. await PowerPoint.run(async (context) => { - const shapes = context.presentation.slides.getItemAt(0).shapes; - const braces = shapes.addGeometricShape(PowerPoint.GeometricShapeType.bracePair, { + 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, diff --git a/generate-docs/API Coverage Report.csv b/generate-docs/API Coverage Report.csv index 8f2df35c66..b1357c7a66 100644 --- a/generate-docs/API Coverage Report.csv +++ b/generate-docs/API Coverage Report.csv @@ -9654,7 +9654,7 @@ PowerPoint.Shape,"textFrame",Property,Good,false PowerPoint.Shape,"top",Property,Good,true PowerPoint.Shape,"type",Property,Good,true PowerPoint.Shape,"width",Property,Good,true -PowerPoint.Shape,"delete()",Method,Poor,false +PowerPoint.Shape,"delete()",Method,Poor,true PowerPoint.Shape,"getParentSlide()",Method,Poor,false PowerPoint.Shape,"getParentSlideLayout()",Method,Poor,false PowerPoint.Shape,"getParentSlideLayoutOrNullObject()",Method,Poor,false @@ -9665,7 +9665,7 @@ PowerPoint.Shape,"load(options)",Method,Poor,false PowerPoint.Shape,"load(propertyNames)",Method,Poor,false PowerPoint.Shape,"load(propertyNamesAndPaths)",Method,Poor,false PowerPoint.Shape,"toJSON()",Method,Poor,false -PowerPoint.ShapeAddOptions,N/A,Class,Good,false +PowerPoint.ShapeAddOptions,N/A,Class,Good,true PowerPoint.ShapeAddOptions,"height",Property,Good,false PowerPoint.ShapeAddOptions,"left",Property,Good,false PowerPoint.ShapeAddOptions,"top",Property,Good,false @@ -9693,7 +9693,7 @@ PowerPoint.ShapeCollection,"load(propertyNamesAndPaths)",Method,Poor,false PowerPoint.ShapeCollection,"toJSON()",Method,Poor,false PowerPoint.ShapeFill,N/A,Class,Good,true PowerPoint.ShapeFill,"context",Property,Good,false -PowerPoint.ShapeFill,"foregroundColor",Property,Good,false +PowerPoint.ShapeFill,"foregroundColor",Property,Good,true PowerPoint.ShapeFill,"transparency",Property,Good,true PowerPoint.ShapeFill,"type",Property,Good,false PowerPoint.ShapeFill,"clear()",Method,Poor,false @@ -9770,10 +9770,10 @@ PowerPoint.ShapeLineStyle,"thickBetweenThin",EnumField,Fine,false PowerPoint.ShapeLineStyle,"thickThin",EnumField,Good,false PowerPoint.ShapeLineStyle,"thinThick",EnumField,Good,false PowerPoint.ShapeLineStyle,"thinThin",EnumField,Fine,false -PowerPoint.ShapeScopedCollection,N/A,Class,Good,false +PowerPoint.ShapeScopedCollection,N/A,Class,Good,true PowerPoint.ShapeScopedCollection,"context",Property,Good,false PowerPoint.ShapeScopedCollection,"items",Property,Fine,false -PowerPoint.ShapeScopedCollection,"getCount()",Method,Fine,false +PowerPoint.ShapeScopedCollection,"getCount()",Method,Fine,true PowerPoint.ShapeScopedCollection,"getItem(key)",Method,Fine,false PowerPoint.ShapeScopedCollection,"getItemAt(index)",Method,Fine,false PowerPoint.ShapeScopedCollection,"getItemOrNullObject(id)",Method,Fine,false @@ -9863,7 +9863,7 @@ PowerPoint.SlideMasterCollection,"load(options)",Method,Poor,false PowerPoint.SlideMasterCollection,"load(propertyNames)",Method,Fine,true PowerPoint.SlideMasterCollection,"load(propertyNamesAndPaths)",Method,Poor,false PowerPoint.SlideMasterCollection,"toJSON()",Method,Poor,false -PowerPoint.SlideScopedCollection,N/A,Class,Good,false +PowerPoint.SlideScopedCollection,N/A,Class,Good,true PowerPoint.SlideScopedCollection,"context",Property,Good,false PowerPoint.SlideScopedCollection,"items",Property,Fine,false PowerPoint.SlideScopedCollection,"getCount()",Method,Fine,false @@ -9874,7 +9874,7 @@ PowerPoint.SlideScopedCollection,"load(options)",Method,Poor,false PowerPoint.SlideScopedCollection,"load(propertyNames)",Method,Poor,false PowerPoint.SlideScopedCollection,"load(propertyNamesAndPaths)",Method,Poor,false PowerPoint.SlideScopedCollection,"toJSON()",Method,Poor,false -PowerPoint.Tag,N/A,Class,Good,false +PowerPoint.Tag,N/A,Class,Good,true PowerPoint.Tag,"context",Property,Good,false PowerPoint.Tag,"key",Property,Good,false PowerPoint.Tag,"value",Property,Good,false @@ -9895,7 +9895,7 @@ PowerPoint.TagCollection,"load(options)",Method,Poor,false PowerPoint.TagCollection,"load(propertyNames)",Method,Poor,false PowerPoint.TagCollection,"load(propertyNamesAndPaths)",Method,Poor,false PowerPoint.TagCollection,"toJSON()",Method,Poor,false -PowerPoint.TextFrame,N/A,Class,Good,false +PowerPoint.TextFrame,N/A,Class,Good,true PowerPoint.TextFrame,"autoSizeSetting",Property,Good,false PowerPoint.TextFrame,"bottomMargin",Property,Good,false PowerPoint.TextFrame,"context",Property,Good,false diff --git a/generate-docs/script-inputs/script-lab-snippets.yaml b/generate-docs/script-inputs/script-lab-snippets.yaml index c98bce98c4..b9b075a173 100644 --- a/generate-docs/script-inputs/script-lab-snippets.yaml +++ b/generate-docs/script-inputs/script-lab-snippets.yaml @@ -14101,11 +14101,11 @@ // start and end points. Then it names the shape. await PowerPoint.run(async (context) => { - const shapes = context.presentation.slides.getItemAt(0).shapes; + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; // 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 = shapes.addLine(PowerPoint.ConnectorType.straight, + const line: PowerPoint.Shape = shapes.addLine(PowerPoint.ConnectorType.straight, { left: 400, top: 200, @@ -14129,14 +14129,14 @@ // location and size. Then it names the shape. await PowerPoint.run(async (context) => { - const shapes = context.presentation.slides.getItemAt(0).shapes; - const hexagon = shapes.addGeometricShape(PowerPoint.GeometricShapeType.hexagon, - { - left: 100, - top: 100, - height: 150, - width: 150 - }); + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; + const shapeOptions: PowerPoint.ShapeAddOptions = { + left: 100, + top: 100, + height: 150, + width: 150 + }; + const hexagon: PowerPoint.Shape = shapes.addGeometricShape(PowerPoint.GeometricShapeType.hexagon, shapeOptions); hexagon.name = "Hexagon"; await context.sync(); @@ -14149,8 +14149,8 @@ await PowerPoint.run(async function(context) { // Get the ID of the first selected slide. - const presentation = context.presentation; - const selected = presentation.getSelectedSlides().getItemAt(0); + const presentation: PowerPoint.Presentation = context.presentation; + const selected: PowerPoint.Slide = presentation.getSelectedSlides().getItemAt(0); selected.load("id"); await context.sync(); @@ -14170,8 +14170,8 @@ await PowerPoint.run(async function(context) { // Get the ID of the first selected slide. - const presentation = context.presentation; - const selected = presentation.getSelectedSlides().getItemAt(0); + const presentation: PowerPoint.Presentation = context.presentation; + const selected: PowerPoint.Slide = presentation.getSelectedSlides().getItemAt(0); selected.load("id"); await context.sync(); @@ -14191,8 +14191,8 @@ await PowerPoint.run(async function(context) { // Get the ID of the first selected slide. - const presentation = context.presentation; - const selected = presentation.getSelectedSlides().getItemAt(0); + const presentation: PowerPoint.Presentation = context.presentation; + const selected: PowerPoint.Slide = presentation.getSelectedSlides().getItemAt(0); selected.load("id"); await context.sync(); @@ -14213,7 +14213,7 @@ // Arranges the selected shapes in a line from left to right. await PowerPoint.run(async (context) => { - const shapes = context.presentation.getSelectedShapes(); + const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes(); const shapeCount = shapes.getCount(); shapes.load("items"); await context.sync(); @@ -14242,7 +14242,7 @@ await PowerPoint.run(async (context) => { let finalTable = ""; - const shapes = context.presentation.getSelectedShapes(); + const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes(); const shapeCount = shapes.getCount(); await context.sync(); finalTable += "
getSelectedShapes.getCount returned:" + shapeCount.value + "
"; @@ -14267,7 +14267,7 @@ await PowerPoint.run(async (context) => { context.presentation.load("slides"); await context.sync(); - const slides = context.presentation.getSelectedSlides(); + const slides: PowerPoint.SlideScopedCollection = context.presentation.getSelectedSlides(); const slideCount = slides.getCount(); slides.load("items"); await context.sync(); @@ -14275,7 +14275,7 @@ slides.items.map((slide) => { savedSlideSelection.push(slide.id); }); - const shapes = context.presentation.getSelectedShapes(); + const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes(); const shapeCount = shapes.getCount(); shapes.load("items"); await context.sync(); @@ -14299,7 +14299,7 @@ const allSlidesCount = context.presentation.slides.getCount(); context.presentation.slides.load("items"); await context.sync(); - let allSlideItems = context.presentation.slides.items; + let allSlideItems: PowerPoint.Slide[] = context.presentation.slides.items; allSlideItems.map((slide, index) => { allSlidesList[slide.id] = `Slide ${index + 1}`; }); @@ -14307,7 +14307,7 @@ if ($("#id-check-usenative").is(":checked")) { context.presentation.load("tags"); } - const slides = context.presentation.getSelectedSlides(); + const slides: PowerPoint.SlideScopedCollection = context.presentation.getSelectedSlides(); const slideCount = slides.getCount(); slides.load("items"); await context.sync(); @@ -14333,7 +14333,7 @@ let finalTable = ""; context.presentation.load("slides"); await context.sync(); - const slides = context.presentation.getSelectedSlides(); + const slides: PowerPoint.SlideScopedCollection = context.presentation.getSelectedSlides(); const slideCount = slides.getCount(); await context.sync(); finalTable += "
getSelectedSlides.getCount returned:" + slideCount.value + "
"; @@ -14360,7 +14360,7 @@ pane. await PowerPoint.run(async (context) => { - const textRange = context.presentation.getSelectedTextRange(); + const textRange: PowerPoint.TextRange = context.presentation.getSelectedTextRange(); try { await context.sync(); } catch (error) { @@ -14399,9 +14399,9 @@ // Sets the range selection to the range that was saved previously. await PowerPoint.run(async (context) => { - const slide1 = context.presentation.slides.getItem(savedTextSlideSelection[0]); - const shape1 = slide1.shapes.getItem(savedTextShapeSelection[0]); - const textRange = shape1.textFrame.textRange.getSubstring(savedTextTextRangeStart, savedTextTextRangeLength); + 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); textRange.setSelected(); await context.sync(); }); @@ -14413,8 +14413,8 @@ await PowerPoint.run(async function(context) { // Get the ID of the first selected slide. - const presentation = context.presentation; - const selected = presentation.getSelectedSlides().getItemAt(0); + const presentation: PowerPoint.Presentation = context.presentation; + const selected: PowerPoint.Slide = presentation.getSelectedSlides().getItemAt(0); selected.load("id"); await context.sync(); @@ -14448,9 +14448,9 @@ await PowerPoint.run(async (context) => { context.presentation.load("slides"); await context.sync(); - const slide2 = context.presentation.slides.getItemAt(1); - const slide4 = context.presentation.slides.getItemAt(3); - const slide5 = context.presentation.slides.getItemAt(4); + const slide2: PowerPoint.Slide = context.presentation.slides.getItemAt(1); + const slide4: PowerPoint.Slide = context.presentation.slides.getItemAt(3); + const slide5: PowerPoint.Slide = context.presentation.slides.getItemAt(4); slide2.load("id"); slide4.load("id"); slide5.load("id"); @@ -14474,7 +14474,7 @@ await PowerPoint.run(async (context) => { // Get the type of shape for every shape in the collection. - const shapes = context.presentation.slides.getItemAt(0).shapes; + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; shapes.load("type"); await context.sync(); @@ -14484,6 +14484,29 @@ shape.fill.transparency = 0.5; } }); + await context.sync(); + }); +'PowerPoint.Shape#delete:member(1)': + - >- + // 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 then iterates through them, deleting each one. + + await PowerPoint.run(async (context) => { + const slide: PowerPoint.Slide = context.presentation.slides.getItemAt(0); + const shapes: PowerPoint.ShapeCollection = slide.shapes; + + // Load all the shapes in the collection without loading their properties. + shapes.load("items/$none"); + + await context.sync(); + + shapes.items.forEach((shape) => shape.delete()); + await context.sync(); }); 'PowerPoint.Shape#fill:member': @@ -14495,7 +14518,7 @@ // Changes the selected shapes fill color to red. await PowerPoint.run(async (context) => { - const shapes = context.presentation.getSelectedShapes(); + const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes(); const shapeCount = shapes.getCount(); shapes.load("items"); await context.sync(); @@ -14513,7 +14536,7 @@ // Arranges the selected shapes in a line from left to right. await PowerPoint.run(async (context) => { - const shapes = context.presentation.getSelectedShapes(); + const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes(); const shapeCount = shapes.getCount(); shapes.load("items"); await context.sync(); @@ -14541,7 +14564,7 @@ // Arranges the selected shapes in a line from left to right. await PowerPoint.run(async (context) => { - const shapes = context.presentation.getSelectedShapes(); + const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes(); const shapeCount = shapes.getCount(); shapes.load("items"); await context.sync(); @@ -14569,7 +14592,7 @@ // Arranges the selected shapes in a line from left to right. await PowerPoint.run(async (context) => { - const shapes = context.presentation.getSelectedShapes(); + const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes(); const shapeCount = shapes.getCount(); shapes.load("items"); await context.sync(); @@ -14598,7 +14621,7 @@ await PowerPoint.run(async (context) => { // Get the type of shape for every shape in the collection. - const shapes = context.presentation.slides.getItemAt(0).shapes; + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; shapes.load("type"); await context.sync(); @@ -14619,7 +14642,7 @@ // Arranges the selected shapes in a line from left to right. await PowerPoint.run(async (context) => { - const shapes = context.presentation.getSelectedShapes(); + const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes(); const shapeCount = shapes.getCount(); shapes.load("items"); await context.sync(); @@ -14638,6 +14661,31 @@ currentLeft = 0; if (currentTop > slideHeight - 200) currentTop = 0; }); +'PowerPoint.ShapeAddOptions:interface': + - >- + // 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 hexagon shape to the collection, while specifying its + + // location and size. Then it names the shape. + + await PowerPoint.run(async (context) => { + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; + const shapeOptions: PowerPoint.ShapeAddOptions = { + left: 100, + top: 100, + height: 150, + width: 150 + }; + const hexagon: PowerPoint.Shape = shapes.addGeometricShape(PowerPoint.GeometricShapeType.hexagon, shapeOptions); + hexagon.name = "Hexagon"; + + await context.sync(); + }); 'PowerPoint.ShapeCollection:class': - >- // Link to full sample: @@ -14648,7 +14696,7 @@ await PowerPoint.run(async (context) => { // Get the type of shape for every shape in the collection. - const shapes = context.presentation.slides.getItemAt(0).shapes; + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; shapes.load("type"); await context.sync(); @@ -14673,14 +14721,14 @@ // location and size. Then it names the shape. await PowerPoint.run(async (context) => { - const shapes = context.presentation.slides.getItemAt(0).shapes; - const hexagon = shapes.addGeometricShape(PowerPoint.GeometricShapeType.hexagon, - { - left: 100, - top: 100, - height: 150, - width: 150 - }); + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; + const shapeOptions: PowerPoint.ShapeAddOptions = { + left: 100, + top: 100, + height: 150, + width: 150 + }; + const hexagon: PowerPoint.Shape = shapes.addGeometricShape(PowerPoint.GeometricShapeType.hexagon, shapeOptions); hexagon.name = "Hexagon"; await context.sync(); @@ -14698,11 +14746,11 @@ // start and end points. Then it names the shape. await PowerPoint.run(async (context) => { - const shapes = context.presentation.slides.getItemAt(0).shapes; + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; // 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 = shapes.addLine(PowerPoint.ConnectorType.straight, + const line: PowerPoint.Shape = shapes.addLine(PowerPoint.ConnectorType.straight, { left: 400, top: 200, @@ -14726,8 +14774,8 @@ // location, and size. Then it names the text box. await PowerPoint.run(async (context) => { - const shapes = context.presentation.slides.getItemAt(0).shapes; - const textbox = shapes.addTextBox("Hello!", + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; + const textbox: PowerPoint.Shape = shapes.addTextBox("Hello!", { left: 100, top: 300, @@ -14745,13 +14793,13 @@ await PowerPoint.run(async function(context) { - const slide = context.presentation.slides.getItemAt(0); - const shape = slide.shapes.getItemAt(0); + const slide: PowerPoint.Slide = context.presentation.slides.getItemAt(0); + const shape: PowerPoint.Shape = slide.shapes.getItemAt(0); shape.tags.add("MOUNTAIN", "Denali"); await context.sync(); - const myShapeTag = shape.tags.getItem("MOUNTAIN"); + const myShapeTag: PowerPoint.Tag = shape.tags.getItem("MOUNTAIN"); myShapeTag.load("key, value"); await context.sync(); @@ -14768,7 +14816,7 @@ await PowerPoint.run(async (context) => { // Get the type of shape for every shape in the collection. - const shapes = context.presentation.slides.getItemAt(0).shapes; + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; shapes.load("type"); await context.sync(); @@ -14790,7 +14838,7 @@ await PowerPoint.run(async (context) => { // Get the type of shape for every shape in the collection. - const shapes = context.presentation.slides.getItemAt(0).shapes; + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; shapes.load("type"); await context.sync(); @@ -14802,6 +14850,33 @@ }); await context.sync(); }); +'PowerPoint.ShapeFill#foregroundColor:member': + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/get-set-shapes.yaml + + + // Creates random shapes on the selected slide. + + await PowerPoint.run(async (context) => { + let finalTable = ""; + const currentSlide: PowerPoint.Slide = context.presentation.getSelectedSlides().getItemAt(0); + const maxNewShapeWidth = 200; + const maxNewShapeHeight = 200; + const minNewShapeWidth = 50; + const minNewShapeHeight = 50; + for (let i = 0; i < 20; i++) { + const rectangle: PowerPoint.Shape = currentSlide.shapes.addGeometricShape(PowerPoint.GeometricShapeType.rectangle); + rectangle.height = getRandomBetween(minNewShapeWidth, maxNewShapeWidth); + rectangle.width = getRandomBetween(minNewShapeHeight, maxNewShapeHeight); + rectangle.left = getRandomBetween(0, slideWidth - rectangle.width); + rectangle.top = getRandomBetween(0, slideHeight - rectangle.height); + rectangle.fill.foregroundColor = generateRandomHexColor(); + } + finalTable += "Done
"; + $("#slide-tags").empty(); + $("#slide-tags").append(finalTable); + }); 'PowerPoint.ShapeFill#setSolidColor:member(1)': - >- // Link to full sample: @@ -14811,7 +14886,7 @@ // Changes the selected shapes fill color to red. await PowerPoint.run(async (context) => { - const shapes = context.presentation.getSelectedShapes(); + const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes(); const shapeCount = shapes.getCount(); shapes.load("items"); await context.sync(); @@ -14830,7 +14905,7 @@ await PowerPoint.run(async (context) => { // Get the type of shape for every shape in the collection. - const shapes = context.presentation.slides.getItemAt(0).shapes; + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; shapes.load("type"); await context.sync(); @@ -14851,7 +14926,7 @@ // Sets the color of the selected text range to green. await PowerPoint.run(async (context) => { - const textRange = context.presentation.getSelectedTextRange(); + const textRange: PowerPoint.TextRange = context.presentation.getSelectedTextRange(); textRange.font.color = "green"; await context.sync(); }); @@ -14864,7 +14939,7 @@ // Sets the color of the selected text range to green. await PowerPoint.run(async (context) => { - const textRange = context.presentation.getSelectedTextRange(); + const textRange: PowerPoint.TextRange = context.presentation.getSelectedTextRange(); textRange.font.color = "green"; await context.sync(); }); @@ -14878,7 +14953,7 @@ await PowerPoint.run(async (context) => { // Get the type of shape for every shape in the collection. - const shapes = context.presentation.slides.getItemAt(0).shapes; + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; shapes.load("type"); await context.sync(); @@ -14900,7 +14975,7 @@ await PowerPoint.run(async (context) => { // Get the type of shape for every shape in the collection. - const shapes = context.presentation.slides.getItemAt(0).shapes; + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; shapes.load("type"); await context.sync(); @@ -14922,7 +14997,7 @@ await PowerPoint.run(async (context) => { // Get the type of shape for every shape in the collection. - const shapes = context.presentation.slides.getItemAt(0).shapes; + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; shapes.load("type"); await context.sync(); @@ -14934,6 +15009,50 @@ }); await context.sync(); }); +'PowerPoint.ShapeScopedCollection:class': + - >- + // 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"); + await context.sync(); + shapes.items.map((shape) => { + shape.fill.setSolidColor("red"); + }); + await context.sync(); + }); +'PowerPoint.ShapeScopedCollection#getCount:member(1)': + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/get-set-shapes.yaml + + + // Gets the shapes you selected on the slide and displays their IDs on the + task pane. + + await PowerPoint.run(async (context) => { + let finalTable = ""; + const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes(); + const shapeCount = shapes.getCount(); + await context.sync(); + finalTable += "
getSelectedShapes.getCount returned:" + shapeCount.value + "
"; + finalTable += + "
"; + shapes.load("items"); + await context.sync(); + shapes.items.map((shape, index) => { + finalTable += ""; + }); + finalTable += "
IndexId
" + index + "" + shape.id + "
"; + $("#outputSpan").empty(); + $("#outputSpan").append(finalTable); + }); 'PowerPoint.ShapeType:enum': - >- // Link to full sample: @@ -14944,7 +15063,7 @@ await PowerPoint.run(async (context) => { // Get the type of shape for every shape in the collection. - const shapes = context.presentation.slides.getItemAt(0).shapes; + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; shapes.load("type"); await context.sync(); @@ -14965,7 +15084,7 @@ // Reselects shapes that were saved previously. await PowerPoint.run(async (context) => { - const slide1 = context.presentation.slides.getItem(savedSlideSelection[0]); + const slide1: PowerPoint.Slide = context.presentation.slides.getItem(savedSlideSelection[0]); await context.sync(); slide1.setSelectedShapes(savedShapeSelection); await context.sync(); @@ -14981,7 +15100,7 @@ await PowerPoint.run(async (context) => { context.presentation.load("slides"); await context.sync(); - const slides = context.presentation.getSelectedSlides(); + const slides: PowerPoint.SlideScopedCollection = context.presentation.getSelectedSlides(); const slideCount = slides.getCount(); slides.load("items"); await context.sync(); @@ -14998,7 +15117,7 @@ // Reselects shapes that were saved previously. await PowerPoint.run(async (context) => { - const slide1 = context.presentation.slides.getItem(savedSlideSelection[0]); + const slide1: PowerPoint.Slide = context.presentation.slides.getItem(savedSlideSelection[0]); await context.sync(); slide1.setSelectedShapes(savedShapeSelection); await context.sync(); @@ -15016,9 +15135,9 @@ const slide1 = context.presentation.slides.getItemAt(0); slide1.load("shapes"); await context.sync(); - const shapes = slide1.shapes; - const shape1 = shapes.getItemAt(0); - const shape2 = shapes.getItemAt(1); + const shapes: PowerPoint.ShapeCollection = slide1.shapes; + const shape1: PowerPoint.Shape = shapes.getItemAt(0); + const shape2: PowerPoint.Shape = shapes.getItemAt(1); shape1.load("id"); shape2.load("id"); await context.sync(); @@ -15076,9 +15195,9 @@ await PowerPoint.run(async (context) => { context.presentation.load("slides"); await context.sync(); - const slide2 = context.presentation.slides.getItemAt(1); - const slide4 = context.presentation.slides.getItemAt(3); - const slide5 = context.presentation.slides.getItemAt(4); + const slide2: PowerPoint.Slide = context.presentation.slides.getItemAt(1); + const slide4: PowerPoint.Slide = context.presentation.slides.getItemAt(3); + const slide5: PowerPoint.Slide = context.presentation.slides.getItemAt(4); slide2.load("id"); slide4.load("id"); slide5.load("id"); @@ -15100,7 +15219,7 @@ await PowerPoint.run(async function(context) { // Load information about all the slide masters and associated layouts. - const slideMasters = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); + const slideMasters: PowerPoint.SlideMasterCollection = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); await context.sync(); // Log the name and ID of each slide master. @@ -15109,7 +15228,7 @@ console.log("Master ID: " + slideMasters.items[i].id); // Log the name and ID of each slide layout in the slide master. - const layoutsInMaster = slideMasters.items[i].layouts; + const layoutsInMaster: PowerPoint.SlideLayoutCollection = slideMasters.items[i].layouts; for (let j = 0; j < layoutsInMaster.items.length; j++) { console.log(" Layout name: " + layoutsInMaster.items[j].name + " Layout ID: " + layoutsInMaster.items[j].id); } @@ -15123,7 +15242,7 @@ await PowerPoint.run(async function(context) { // Load information about all the slide masters and associated layouts. - const slideMasters = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); + const slideMasters: PowerPoint.SlideMasterCollection = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); await context.sync(); // Log the name and ID of each slide master. @@ -15132,7 +15251,7 @@ console.log("Master ID: " + slideMasters.items[i].id); // Log the name and ID of each slide layout in the slide master. - const layoutsInMaster = slideMasters.items[i].layouts; + const layoutsInMaster: PowerPoint.SlideLayoutCollection = slideMasters.items[i].layouts; for (let j = 0; j < layoutsInMaster.items.length; j++) { console.log(" Layout name: " + layoutsInMaster.items[j].name + " Layout ID: " + layoutsInMaster.items[j].id); } @@ -15146,7 +15265,7 @@ await PowerPoint.run(async function(context) { // Load information about all the slide masters and associated layouts. - const slideMasters = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); + const slideMasters: PowerPoint.SlideMasterCollection = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); await context.sync(); // Log the name and ID of each slide master. @@ -15155,7 +15274,7 @@ console.log("Master ID: " + slideMasters.items[i].id); // Log the name and ID of each slide layout in the slide master. - const layoutsInMaster = slideMasters.items[i].layouts; + const layoutsInMaster: PowerPoint.SlideLayoutCollection = slideMasters.items[i].layouts; for (let j = 0; j < layoutsInMaster.items.length; j++) { console.log(" Layout name: " + layoutsInMaster.items[j].name + " Layout ID: " + layoutsInMaster.items[j].id); } @@ -15169,7 +15288,7 @@ await PowerPoint.run(async function(context) { // Load information about all the slide masters and associated layouts. - const slideMasters = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); + const slideMasters: PowerPoint.SlideMasterCollection = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); await context.sync(); // Log the name and ID of each slide master. @@ -15178,7 +15297,7 @@ console.log("Master ID: " + slideMasters.items[i].id); // Log the name and ID of each slide layout in the slide master. - const layoutsInMaster = slideMasters.items[i].layouts; + const layoutsInMaster: PowerPoint.SlideLayoutCollection = slideMasters.items[i].layouts; for (let j = 0; j < layoutsInMaster.items.length; j++) { console.log(" Layout name: " + layoutsInMaster.items[j].name + " Layout ID: " + layoutsInMaster.items[j].id); } @@ -15192,7 +15311,7 @@ await PowerPoint.run(async function(context) { // Load information about all the slide masters and associated layouts. - const slideMasters = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); + const slideMasters: PowerPoint.SlideMasterCollection = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); await context.sync(); // Log the name and ID of each slide master. @@ -15201,7 +15320,7 @@ console.log("Master ID: " + slideMasters.items[i].id); // Log the name and ID of each slide layout in the slide master. - const layoutsInMaster = slideMasters.items[i].layouts; + const layoutsInMaster: PowerPoint.SlideLayoutCollection = slideMasters.items[i].layouts; for (let j = 0; j < layoutsInMaster.items.length; j++) { console.log(" Layout name: " + layoutsInMaster.items[j].name + " Layout ID: " + layoutsInMaster.items[j].id); } @@ -15215,7 +15334,7 @@ await PowerPoint.run(async function(context) { // Load information about all the slide masters and associated layouts. - const slideMasters = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); + const slideMasters: PowerPoint.SlideMasterCollection = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); await context.sync(); // Log the name and ID of each slide master. @@ -15224,7 +15343,7 @@ console.log("Master ID: " + slideMasters.items[i].id); // Log the name and ID of each slide layout in the slide master. - const layoutsInMaster = slideMasters.items[i].layouts; + const layoutsInMaster: PowerPoint.SlideLayoutCollection = slideMasters.items[i].layouts; for (let j = 0; j < layoutsInMaster.items.length; j++) { console.log(" Layout name: " + layoutsInMaster.items[j].name + " Layout ID: " + layoutsInMaster.items[j].id); } @@ -15238,7 +15357,7 @@ await PowerPoint.run(async function(context) { // Load information about all the slide masters and associated layouts. - const slideMasters = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); + const slideMasters: PowerPoint.SlideMasterCollection = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); await context.sync(); // Log the name and ID of each slide master. @@ -15247,7 +15366,7 @@ console.log("Master ID: " + slideMasters.items[i].id); // Log the name and ID of each slide layout in the slide master. - const layoutsInMaster = slideMasters.items[i].layouts; + const layoutsInMaster: PowerPoint.SlideLayoutCollection = slideMasters.items[i].layouts; for (let j = 0; j < layoutsInMaster.items.length; j++) { console.log(" Layout name: " + layoutsInMaster.items[j].name + " Layout ID: " + layoutsInMaster.items[j].id); } @@ -15261,7 +15380,7 @@ await PowerPoint.run(async function(context) { // Load information about all the slide masters and associated layouts. - const slideMasters = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); + const slideMasters: PowerPoint.SlideMasterCollection = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); await context.sync(); // Log the name and ID of each slide master. @@ -15270,12 +15389,58 @@ console.log("Master ID: " + slideMasters.items[i].id); // Log the name and ID of each slide layout in the slide master. - const layoutsInMaster = slideMasters.items[i].layouts; + const layoutsInMaster: PowerPoint.SlideLayoutCollection = slideMasters.items[i].layouts; for (let j = 0; j < layoutsInMaster.items.length; j++) { console.log(" Layout name: " + layoutsInMaster.items[j].name + " Layout ID: " + layoutsInMaster.items[j].id); } } }); +'PowerPoint.SlideScopedCollection:class': + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/get-set-shapes.yaml + + + // Saves which shapes are selected so that they can be reselected later. + + await PowerPoint.run(async (context) => { + context.presentation.load("slides"); + await context.sync(); + const slides: PowerPoint.SlideScopedCollection = context.presentation.getSelectedSlides(); + const slideCount = slides.getCount(); + slides.load("items"); + await context.sync(); + savedSlideSelection = []; + slides.items.map((slide) => { + savedSlideSelection.push(slide.id); + }); + const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes(); + const shapeCount = shapes.getCount(); + shapes.load("items"); + await context.sync(); + shapes.items.map((shape) => { + savedShapeSelection.push(shape.id); + }); + }); +'PowerPoint.Tag:class': + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/tags/tags.yaml + + + await PowerPoint.run(async function (context) { + let presentationTags: PowerPoint.TagCollection = context.presentation.tags; + presentationTags.add("COLOR", "blue"); + + await context.sync(); + + const tag: PowerPoint.Tag = presentationTags.getItem("COLOR"); + tag.load("key, value"); + + await context.sync(); + + console.log("Added key " + JSON.stringify(tag.key) + " with value " + JSON.stringify(tag.value)); + }); 'PowerPoint.TagCollection:class': - >- // Link to full sample: @@ -15288,12 +15453,12 @@ // Decrement because the getSelectedSlideByIndex method is 1-based, // but the getItemAt method is 0-based. selectedSlideIndex = selectedSlideIndex - 1; - const slide = context.presentation.slides.getItemAt(selectedSlideIndex); + const slide: PowerPoint.Slide = context.presentation.slides.getItemAt(selectedSlideIndex); slide.tags.add("CUSTOMER_TYPE", "Premium"); await context.sync(); - const audienceTag = slide.tags.getItem("CUSTOMER_TYPE"); + const audienceTag: PowerPoint.Tag = slide.tags.getItem("CUSTOMER_TYPE"); audienceTag.load("key, value"); await context.sync(); @@ -15307,7 +15472,7 @@ await PowerPoint.run(async function(context) { - const slide = context.presentation.slides.getItemAt(0); + const slide: PowerPoint.Slide = context.presentation.slides.getItemAt(0); slide.tags.add("OCEAN", "Indian"); slide.tags.add("PLANET", "Jupiter"); slide.tags.add("CONTINENT", "Antarctica"); @@ -15329,7 +15494,7 @@ await PowerPoint.run(async function (context) { - let presentationTags = context.presentation.tags; + let presentationTags: PowerPoint.TagCollection = context.presentation.tags; presentationTags.delete("COLOR"); @@ -15349,18 +15514,52 @@ // Decrement because the getSelectedSlideByIndex method is 1-based, // but the getItemAt method is 0-based. selectedSlideIndex = selectedSlideIndex - 1; - const slide = context.presentation.slides.getItemAt(selectedSlideIndex); + const slide: PowerPoint.Slide = context.presentation.slides.getItemAt(selectedSlideIndex); slide.tags.add("CUSTOMER_TYPE", "Premium"); await context.sync(); - const audienceTag = slide.tags.getItem("CUSTOMER_TYPE"); + const audienceTag: PowerPoint.Tag = slide.tags.getItem("CUSTOMER_TYPE"); audienceTag.load("key, value"); await context.sync(); console.log("Added key " + JSON.stringify(audienceTag.key) + " with value " + JSON.stringify(audienceTag.value)); }); +'PowerPoint.TextFrame:class': + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/text/get-set-textrange.yaml + + + // Selects the first 10 characters of the selected shape. + + await PowerPoint.run(async (context) => { + const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes(); + const shapeCount = shapes.getCount(); + await context.sync(); + if (shapeCount.value !== 1) { + console.warn("You must select only one shape with text in it."); + return; + } + const shape: PowerPoint.Shape = shapes.getItemAt(0); + const textFrame: PowerPoint.TextFrame = shape.textFrame.load("textRange,hasText"); + await context.sync(); + if (textFrame.hasText != true) { + console.warn("You must select only one shape with text in it."); + return; + } + const textRange: PowerPoint.TextRange = textFrame.textRange; + textRange.load("text"); + await context.sync(); + if (textRange.text.length < 10) { + console.warn("You must select only one shape with at least 10 characters in it."); + return; + } + const textRange10 = textRange.getSubstring(0, 10); + textRange10.setSelected(); + await context.sync(); + }); 'PowerPoint.TextRange:class': - >- // Link to full sample: @@ -15370,7 +15569,7 @@ // Sets the color of the selected text range to green. await PowerPoint.run(async (context) => { - const textRange = context.presentation.getSelectedTextRange(); + const textRange: PowerPoint.TextRange = context.presentation.getSelectedTextRange(); textRange.font.color = "green"; await context.sync(); }); @@ -15383,7 +15582,7 @@ // Sets the color of the selected text range to green. await PowerPoint.run(async (context) => { - const textRange = context.presentation.getSelectedTextRange(); + const textRange: PowerPoint.TextRange = context.presentation.getSelectedTextRange(); textRange.font.color = "green"; await context.sync(); }); @@ -15396,21 +15595,21 @@ // Selects the first 10 characters of the selected shape. await PowerPoint.run(async (context) => { - const shapes = context.presentation.getSelectedShapes(); + const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes(); const shapeCount = shapes.getCount(); await context.sync(); if (shapeCount.value !== 1) { console.warn("You must select only one shape with text in it."); return; } - const shape = shapes.getItemAt(0); - const textFrame = shape.textFrame.load("textRange,hasText"); + const shape: PowerPoint.Shape = shapes.getItemAt(0); + const textFrame: PowerPoint.TextFrame = shape.textFrame.load("textRange,hasText"); await context.sync(); if (textFrame.hasText != true) { console.warn("You must select only one shape with text in it."); return; } - const textRange = textFrame.textRange; + const textRange: PowerPoint.TextRange = textFrame.textRange; textRange.load("text"); await context.sync(); if (textRange.text.length < 10) { @@ -15429,9 +15628,9 @@ // Sets the range selection to the range that was saved previously. await PowerPoint.run(async (context) => { - const slide1 = context.presentation.slides.getItem(savedTextSlideSelection[0]); - const shape1 = slide1.shapes.getItem(savedTextShapeSelection[0]); - const textRange = shape1.textFrame.textRange.getSubstring(savedTextTextRangeStart, savedTextTextRangeLength); + 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); textRange.setSelected(); await context.sync(); }); @@ -15450,8 +15649,8 @@ // color, and centers it inside the braces. await PowerPoint.run(async (context) => { - const shapes = context.presentation.slides.getItemAt(0).shapes; - const braces = shapes.addGeometricShape(PowerPoint.GeometricShapeType.bracePair, { + 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,