You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In PowerPoint, you can group several shapes and treat them like a single shape. You can subsequently ungroup grouped shapes. To learn more about grouping objects in the PowerPoint UI, see [Group or ungroup shapes, pictures, or other objects](https://support.microsoft.com/office/a7374c35-20fe-4e0a-9637-7de7d844724b).
108
+
109
+
### Group shapes
110
+
111
+
To group shapes with the JavaScript API, use [ShapeCollection.addGroup](/javascript/api/powerpoint/powerpoint.shapecollection#powerpoint-powerpoint-shapecollection-addgroup-member(1)).
112
+
113
+
The following example code shows how to group existing shapes of type [GeometricShape](/javascript/api/powerpoint/powerpoint.shapetype) found on the current slide.
114
+
115
+
```typescript
116
+
// Groups the geometric shapes on the current slide.
console.log(`Number of shapes to group: ${shapesToGroup.length}`);
131
+
const group =shapes.addGroup(shapesToGroup);
132
+
group.load("id");
133
+
awaitcontext.sync();
134
+
135
+
console.log(`Grouped shapes. Group ID: ${group.id}`);
136
+
});
137
+
```
138
+
139
+
### Ungroup shapes
140
+
141
+
To ungroup shapes with the JavaScript API, get the [group](/javascript/api/powerpoint/powerpoint.shape#powerpoint-powerpoint-shape-group-member) property from the group's `Shape` object then call [ShapeGroup.ungroup](/javascript/api/powerpoint/powerpoint.shapegroup#powerpoint-powerpoint-shapegroup-ungroup-member(1)).
142
+
143
+
The following code shows how to ungroup the first shape group found on the current slide.
144
+
145
+
```typescript
146
+
// Ungroups the first shape group on the current slide.
0 commit comments