@@ -15776,20 +15776,17 @@
1577615776      // Get the shapes on the current slide.
1577715777      context.presentation.load("slides");
1577815778      const slide: PowerPoint.Slide = context.presentation.getSelectedSlides().getItemAt(0);
15779-       slide.load("shapes");
15779+       slide.load("shapes/items/type,shapes/items/id ");
1578015780      await context.sync();
1578115781
1578215782      const shapes: PowerPoint.ShapeCollection = slide.shapes;
15783-       shapes.load("items/type,items/id");
15784-       await context.sync();
15785- 
15786-       // Ungroup the first grouped shapes.
1578715783      const shapeGroups = shapes.items.filter((item) => item.type === PowerPoint.ShapeType.group);
15788-       if (shapeGroups.length == 0) {
15789-         console.warn("No shape groups on the current slide so nothing to ungroup.");
15784+       if (shapeGroups.length ===  0) {
15785+         console.warn("No shape groups on the current slide,  so nothing to ungroup.");
1579015786        return;
1579115787      }
1579215788
15789+       // Ungroup the first grouped shapes.
1579315790      const firstGroupId = shapeGroups[0].id;
1579415791      const shapeGroupToUngroup = shapes.getItem(firstGroupId);
1579515792      shapeGroupToUngroup.group.ungroup();
@@ -16015,15 +16012,17 @@
1601516012      // Get the shapes on the current slide.
1601616013      context.presentation.load("slides");
1601716014      const slide: PowerPoint.Slide = context.presentation.getSelectedSlides().getItemAt(0);
16018-       slide.load("shapes");
16015+       slide.load("shapes/items/type,shapes/items/id ");
1601916016      await context.sync();
1602016017
1602116018      const shapes: PowerPoint.ShapeCollection = slide.shapes;
16022-       shapes.load("items/type,items/id");
16023-       await context.sync();
16019+       const shapesToGroup = shapes.items.filter((item) => item.type === PowerPoint.ShapeType.geometricShape);
16020+       if (shapesToGroup.length === 0) {
16021+         console.warn("No shapes on the current slide, so nothing to group.");
16022+         return;
16023+       }
1602416024
1602516025      // Group the geometric shapes.
16026-       const shapesToGroup = shapes.items.filter((item) => item.type === PowerPoint.ShapeType.geometricShape);
1602716026      console.log(`Number of shapes to group: ${shapesToGroup.length}`);
1602816027      const group = shapes.addGroup(shapesToGroup);
1602916028      group.load("id");
@@ -16212,21 +16211,19 @@
1621216211      const minNewShapeWidth = 50;
1621316212      const minNewShapeHeight = 50;
1621416213      for (let i = 0; i < 20; i++) {
16215-         const rectangle: PowerPoint.Shape = currentSlide.shapes.addGeometricShape(PowerPoint.GeometricShapeType.rectangle);
16214+         const rectangle: PowerPoint.Shape = currentSlide.shapes.addGeometricShape(
16215+           PowerPoint.GeometricShapeType.rectangle
16216+         );
1621616217        rectangle.height = getRandomBetween(minNewShapeWidth, maxNewShapeWidth);
1621716218        rectangle.width = getRandomBetween(minNewShapeHeight, maxNewShapeHeight);
1621816219        rectangle.left = getRandomBetween(0, slideWidth - rectangle.width);
1621916220        rectangle.top = getRandomBetween(0, slideHeight - rectangle.height);
1622016221        rectangle.fill.foregroundColor = generateRandomHexColor();
1622116222      }
1622216223      finalTable += "Done<br>";
16223-       const slideTags = document.getElementById("slide-tags");
16224-       if (slideTags) {
16225-         slideTags.innerHTML = "";
16226-         slideTags.innerHTML += finalTable;
16227-       } else {
16228-         console.warn('Element with ID "slide-tags" not found.');
16229-       }
16224+       const outputSpan = document.getElementById("outputSpan");
16225+       outputSpan.innerHTML = "";
16226+       outputSpan.innerHTML += finalTable;
1623016227    });
1623116228'PowerPoint.ShapeFill#setSolidColor:member(1)':
1623216229  - >-
@@ -16306,20 +16303,17 @@
1630616303      // Get the shapes on the current slide.
1630716304      context.presentation.load("slides");
1630816305      const slide: PowerPoint.Slide = context.presentation.getSelectedSlides().getItemAt(0);
16309-       slide.load("shapes");
16306+       slide.load("shapes/items/type,shapes/items/id ");
1631016307      await context.sync();
1631116308
1631216309      const shapes: PowerPoint.ShapeCollection = slide.shapes;
16313-       shapes.load("items/type,items/id");
16314-       await context.sync();
16315- 
16316-       // Ungroup the first grouped shapes.
1631716310      const shapeGroups = shapes.items.filter((item) => item.type === PowerPoint.ShapeType.group);
16318-       if (shapeGroups.length == 0) {
16319-         console.warn("No shape groups on the current slide so nothing to ungroup.");
16311+       if (shapeGroups.length ===  0) {
16312+         console.warn("No shape groups on the current slide,  so nothing to ungroup.");
1632016313        return;
1632116314      }
1632216315
16316+       // Ungroup the first grouped shapes.
1632316317      const firstGroupId = shapeGroups[0].id;
1632416318      const shapeGroupToUngroup = shapes.getItem(firstGroupId);
1632516319      shapeGroupToUngroup.group.ungroup();
@@ -16339,20 +16333,17 @@
1633916333      // Get the shapes on the current slide.
1634016334      context.presentation.load("slides");
1634116335      const slide: PowerPoint.Slide = context.presentation.getSelectedSlides().getItemAt(0);
16342-       slide.load("shapes");
16336+       slide.load("shapes/items/type,shapes/items/id ");
1634316337      await context.sync();
1634416338
1634516339      const shapes: PowerPoint.ShapeCollection = slide.shapes;
16346-       shapes.load("items/type,items/id");
16347-       await context.sync();
16348- 
16349-       // Ungroup the first grouped shapes.
1635016340      const shapeGroups = shapes.items.filter((item) => item.type === PowerPoint.ShapeType.group);
16351-       if (shapeGroups.length == 0) {
16352-         console.warn("No shape groups on the current slide so nothing to ungroup.");
16341+       if (shapeGroups.length ===  0) {
16342+         console.warn("No shape groups on the current slide,  so nothing to ungroup.");
1635316343        return;
1635416344      }
1635516345
16346+       // Ungroup the first grouped shapes.
1635616347      const firstGroupId = shapeGroups[0].id;
1635716348      const shapeGroupToUngroup = shapes.getItem(firstGroupId);
1635816349      shapeGroupToUngroup.group.ungroup();
@@ -16593,14 +16584,17 @@
1659316584      context.presentation.load("slides");
1659416585      await context.sync();
1659516586      const slide1 = context.presentation.slides.getItemAt(0);
16596-       slide1.load("shapes");
16587+       slide1.load("shapes/items/type ");
1659716588      await context.sync();
16598-       const shapes: PowerPoint.ShapeCollection = slide1.shapes;
16599-       const shape1: PowerPoint.Shape = shapes.getItemAt(0);
16600-       const shape2: PowerPoint.Shape = shapes.getItemAt(1);
16589+ 
16590+       const shapes = slide1.shapes.items.filter((item) => item.type === PowerPoint.ShapeType.geometricShape);
16591+       const shape1: PowerPoint.Shape = shapes[0];
16592+       const shape2: PowerPoint.Shape = shapes[1];
1660116593      shape1.load("id");
1660216594      shape2.load("id");
1660316595      await context.sync();
16596+ 
16597+       console.log(`IDs: ${shape1.id}, ${shape2.id}`)
1660416598      slide1.setSelectedShapes([shape1.id, shape2.id]);
1660516599      await context.sync();
1660616600    });
0 commit comments