@@ -15776,20 +15776,17 @@
15776
15776
// Get the shapes on the current slide.
15777
15777
context.presentation.load("slides");
15778
15778
const slide: PowerPoint.Slide = context.presentation.getSelectedSlides().getItemAt(0);
15779
- slide.load("shapes");
15779
+ slide.load("shapes/items/type,shapes/items/id ");
15780
15780
await context.sync();
15781
15781
15782
15782
const shapes: PowerPoint.ShapeCollection = slide.shapes;
15783
- shapes.load("items/type,items/id");
15784
- await context.sync();
15785
-
15786
- // Ungroup the first grouped shapes.
15787
15783
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.");
15790
15786
return;
15791
15787
}
15792
15788
15789
+ // Ungroup the first grouped shapes.
15793
15790
const firstGroupId = shapeGroups[0].id;
15794
15791
const shapeGroupToUngroup = shapes.getItem(firstGroupId);
15795
15792
shapeGroupToUngroup.group.ungroup();
@@ -16015,15 +16012,17 @@
16015
16012
// Get the shapes on the current slide.
16016
16013
context.presentation.load("slides");
16017
16014
const slide: PowerPoint.Slide = context.presentation.getSelectedSlides().getItemAt(0);
16018
- slide.load("shapes");
16015
+ slide.load("shapes/items/type,shapes/items/id ");
16019
16016
await context.sync();
16020
16017
16021
16018
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
+ }
16024
16024
16025
16025
// Group the geometric shapes.
16026
- const shapesToGroup = shapes.items.filter((item) => item.type === PowerPoint.ShapeType.geometricShape);
16027
16026
console.log(`Number of shapes to group: ${shapesToGroup.length}`);
16028
16027
const group = shapes.addGroup(shapesToGroup);
16029
16028
group.load("id");
@@ -16212,21 +16211,19 @@
16212
16211
const minNewShapeWidth = 50;
16213
16212
const minNewShapeHeight = 50;
16214
16213
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
+ );
16216
16217
rectangle.height = getRandomBetween(minNewShapeWidth, maxNewShapeWidth);
16217
16218
rectangle.width = getRandomBetween(minNewShapeHeight, maxNewShapeHeight);
16218
16219
rectangle.left = getRandomBetween(0, slideWidth - rectangle.width);
16219
16220
rectangle.top = getRandomBetween(0, slideHeight - rectangle.height);
16220
16221
rectangle.fill.foregroundColor = generateRandomHexColor();
16221
16222
}
16222
16223
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;
16230
16227
});
16231
16228
'PowerPoint.ShapeFill#setSolidColor:member(1)':
16232
16229
- >-
@@ -16306,20 +16303,17 @@
16306
16303
// Get the shapes on the current slide.
16307
16304
context.presentation.load("slides");
16308
16305
const slide: PowerPoint.Slide = context.presentation.getSelectedSlides().getItemAt(0);
16309
- slide.load("shapes");
16306
+ slide.load("shapes/items/type,shapes/items/id ");
16310
16307
await context.sync();
16311
16308
16312
16309
const shapes: PowerPoint.ShapeCollection = slide.shapes;
16313
- shapes.load("items/type,items/id");
16314
- await context.sync();
16315
-
16316
- // Ungroup the first grouped shapes.
16317
16310
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.");
16320
16313
return;
16321
16314
}
16322
16315
16316
+ // Ungroup the first grouped shapes.
16323
16317
const firstGroupId = shapeGroups[0].id;
16324
16318
const shapeGroupToUngroup = shapes.getItem(firstGroupId);
16325
16319
shapeGroupToUngroup.group.ungroup();
@@ -16339,20 +16333,17 @@
16339
16333
// Get the shapes on the current slide.
16340
16334
context.presentation.load("slides");
16341
16335
const slide: PowerPoint.Slide = context.presentation.getSelectedSlides().getItemAt(0);
16342
- slide.load("shapes");
16336
+ slide.load("shapes/items/type,shapes/items/id ");
16343
16337
await context.sync();
16344
16338
16345
16339
const shapes: PowerPoint.ShapeCollection = slide.shapes;
16346
- shapes.load("items/type,items/id");
16347
- await context.sync();
16348
-
16349
- // Ungroup the first grouped shapes.
16350
16340
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.");
16353
16343
return;
16354
16344
}
16355
16345
16346
+ // Ungroup the first grouped shapes.
16356
16347
const firstGroupId = shapeGroups[0].id;
16357
16348
const shapeGroupToUngroup = shapes.getItem(firstGroupId);
16358
16349
shapeGroupToUngroup.group.ungroup();
@@ -16593,14 +16584,17 @@
16593
16584
context.presentation.load("slides");
16594
16585
await context.sync();
16595
16586
const slide1 = context.presentation.slides.getItemAt(0);
16596
- slide1.load("shapes");
16587
+ slide1.load("shapes/items/type ");
16597
16588
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];
16601
16593
shape1.load("id");
16602
16594
shape2.load("id");
16603
16595
await context.sync();
16596
+
16597
+ console.log(`IDs: ${shape1.id}, ${shape2.id}`)
16604
16598
slide1.setSelectedShapes([shape1.id, shape2.id]);
16605
16599
await context.sync();
16606
16600
});
0 commit comments