|
15221 | 15221 | }); |
15222 | 15222 | await context.sync(); |
15223 | 15223 | }); |
| 15224 | +'PowerPoint.Shape#group:member': |
| 15225 | + - >- |
| 15226 | + // Link to full sample: |
| 15227 | + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/group-ungroup-shapes.yaml |
| 15228 | + |
| 15229 | + |
| 15230 | + await PowerPoint.run(async (context) => { |
| 15231 | + // Ungroups the first shape group on the current slide. |
| 15232 | + |
| 15233 | + // Get the current slide. |
| 15234 | + context.presentation.load("slides"); |
| 15235 | + const slide: PowerPoint.Slide = context.presentation.getSelectedSlides().getItemAt(0); |
| 15236 | + |
| 15237 | + // Get the shapes. |
| 15238 | + slide.load("shapes"); |
| 15239 | + await context.sync(); |
| 15240 | + |
| 15241 | + const shapes: PowerPoint.ShapeCollection = slide.shapes; |
| 15242 | + shapes.load("items/type,items/id"); |
| 15243 | + await context.sync(); |
| 15244 | + |
| 15245 | + // Ungroup the first grouped shapes. |
| 15246 | + const shapeGroups = shapes.items.filter((item) => item.type === PowerPoint.ShapeType.group); |
| 15247 | + if (shapeGroups.length == 0) { |
| 15248 | + console.warn("No shape groups on the current slide so nothing to ungroup."); |
| 15249 | + return; |
| 15250 | + } |
| 15251 | + |
| 15252 | + const firstGroupId = shapeGroups[0].id; |
| 15253 | + const shapeGroupToUngroup = shapes.getItem(firstGroupId); |
| 15254 | + shapeGroupToUngroup.group.ungroup(); |
| 15255 | + await context.sync(); |
| 15256 | + |
| 15257 | + console.log(`Ungrouped shapes with group ID: ${firstGroupId}`); |
| 15258 | + }); |
15224 | 15259 | 'PowerPoint.Shape#height:member': |
15225 | 15260 | - >- |
15226 | 15261 | // Link to full sample: |
|
15427 | 15462 |
|
15428 | 15463 | await context.sync(); |
15429 | 15464 | }); |
| 15465 | +'PowerPoint.ShapeCollection#addGroup:member(1)': |
| 15466 | + - >- |
| 15467 | + // Link to full sample: |
| 15468 | + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/group-ungroup-shapes.yaml |
| 15469 | + |
| 15470 | + |
| 15471 | + await PowerPoint.run(async (context) => { |
| 15472 | + // Groups the geometric shapes on the current slide. |
| 15473 | + |
| 15474 | + // Get the current slide. |
| 15475 | + context.presentation.load("slides"); |
| 15476 | + const slide: PowerPoint.Slide = context.presentation.getSelectedSlides().getItemAt(0); |
| 15477 | + |
| 15478 | + // Get the shapes. |
| 15479 | + slide.load("shapes"); |
| 15480 | + await context.sync(); |
| 15481 | + |
| 15482 | + const shapes: PowerPoint.ShapeCollection = slide.shapes; |
| 15483 | + shapes.load("items/type,items/id"); |
| 15484 | + await context.sync(); |
| 15485 | + |
| 15486 | + // Group the geometric shapes. |
| 15487 | + const shapesToGroup = shapes.items.filter((item) => item.type === PowerPoint.ShapeType.geometricShape); |
| 15488 | + console.log(`Number of shapes to group: ${shapesToGroup.length}`); |
| 15489 | + const group = shapes.addGroup(shapesToGroup); |
| 15490 | + group.load("id"); |
| 15491 | + await context.sync(); |
| 15492 | + |
| 15493 | + console.log(`Grouped shapes. Group ID: ${group.id}`); |
| 15494 | + }); |
15430 | 15495 | 'PowerPoint.ShapeCollection#addLine:member(1)': |
15431 | 15496 | - >- |
15432 | 15497 | // Link to full sample: |
|
15642 | 15707 | textRange.font.color = "green"; |
15643 | 15708 | await context.sync(); |
15644 | 15709 | }); |
| 15710 | +'PowerPoint.ShapeGroup:class': |
| 15711 | + - >- |
| 15712 | + // Link to full sample: |
| 15713 | + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/group-ungroup-shapes.yaml |
| 15714 | + |
| 15715 | + |
| 15716 | + await PowerPoint.run(async (context) => { |
| 15717 | + // Ungroups the first shape group on the current slide. |
| 15718 | + |
| 15719 | + // Get the current slide. |
| 15720 | + context.presentation.load("slides"); |
| 15721 | + const slide: PowerPoint.Slide = context.presentation.getSelectedSlides().getItemAt(0); |
| 15722 | + |
| 15723 | + // Get the shapes. |
| 15724 | + slide.load("shapes"); |
| 15725 | + await context.sync(); |
| 15726 | + |
| 15727 | + const shapes: PowerPoint.ShapeCollection = slide.shapes; |
| 15728 | + shapes.load("items/type,items/id"); |
| 15729 | + await context.sync(); |
| 15730 | + |
| 15731 | + // Ungroup the first grouped shapes. |
| 15732 | + const shapeGroups = shapes.items.filter((item) => item.type === PowerPoint.ShapeType.group); |
| 15733 | + if (shapeGroups.length == 0) { |
| 15734 | + console.warn("No shape groups on the current slide so nothing to ungroup."); |
| 15735 | + return; |
| 15736 | + } |
| 15737 | + |
| 15738 | + const firstGroupId = shapeGroups[0].id; |
| 15739 | + const shapeGroupToUngroup = shapes.getItem(firstGroupId); |
| 15740 | + shapeGroupToUngroup.group.ungroup(); |
| 15741 | + await context.sync(); |
| 15742 | + |
| 15743 | + console.log(`Ungrouped shapes with group ID: ${firstGroupId}`); |
| 15744 | + }); |
| 15745 | +'PowerPoint.ShapeGroup#ungroup:member(1)': |
| 15746 | + - >- |
| 15747 | + // Link to full sample: |
| 15748 | + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/group-ungroup-shapes.yaml |
| 15749 | + |
| 15750 | + |
| 15751 | + await PowerPoint.run(async (context) => { |
| 15752 | + // Ungroups the first shape group on the current slide. |
| 15753 | + |
| 15754 | + // Get the current slide. |
| 15755 | + context.presentation.load("slides"); |
| 15756 | + const slide: PowerPoint.Slide = context.presentation.getSelectedSlides().getItemAt(0); |
| 15757 | + |
| 15758 | + // Get the shapes. |
| 15759 | + slide.load("shapes"); |
| 15760 | + await context.sync(); |
| 15761 | + |
| 15762 | + const shapes: PowerPoint.ShapeCollection = slide.shapes; |
| 15763 | + shapes.load("items/type,items/id"); |
| 15764 | + await context.sync(); |
| 15765 | + |
| 15766 | + // Ungroup the first grouped shapes. |
| 15767 | + const shapeGroups = shapes.items.filter((item) => item.type === PowerPoint.ShapeType.group); |
| 15768 | + if (shapeGroups.length == 0) { |
| 15769 | + console.warn("No shape groups on the current slide so nothing to ungroup."); |
| 15770 | + return; |
| 15771 | + } |
| 15772 | + |
| 15773 | + const firstGroupId = shapeGroups[0].id; |
| 15774 | + const shapeGroupToUngroup = shapes.getItem(firstGroupId); |
| 15775 | + shapeGroupToUngroup.group.ungroup(); |
| 15776 | + await context.sync(); |
| 15777 | + |
| 15778 | + console.log(`Ungrouped shapes with group ID: ${firstGroupId}`); |
| 15779 | + }); |
15645 | 15780 | 'PowerPoint.ShapeLineDashStyle:enum': |
15646 | 15781 | - >- |
15647 | 15782 | // Link to full sample: |
|
0 commit comments