@@ -26552,6 +26552,34 @@ Word.Paragraph#insertContentControl:member(1):
2655226552 }
2655326553 console.log("Content controls inserted: " + paragraphs.items.length);
2655426554
26555+ await context.sync();
26556+ });
26557+ Word.Paragraph#insertGeometricShape:member(1):
26558+ - >-
26559+ // Link to full sample:
26560+ https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/group-ungroup.yaml
26561+
26562+
26563+ await Word.run(async (context) => {
26564+ const body: Word.Body = context.document.body;
26565+ body.clear();
26566+
26567+ // Inserts a text box.
26568+ const textBoxOptions: Word.InsertShapeOptions = {
26569+ top: 0,
26570+ left: 0,
26571+ height: 100,
26572+ width: 100,
26573+ };
26574+ body.paragraphs.getLast().insertTextBox("placeholder text", textBoxOptions);
26575+
26576+ // Inserts a geometric shape.
26577+ const geometricShapeOptions: Word.InsertShapeOptions = {
26578+ height: 120,
26579+ width: 120,
26580+ left: 120,
26581+ };
26582+ body.paragraphs.getLast().insertGeometricShape(Word.GeometricShapeType.star24, geometricShapeOptions);
2655526583 await context.sync();
2655626584 });
2655726585Word.Paragraph#insertText:member(1):
@@ -27965,6 +27993,37 @@ Word.Shape#delete:member(1):
2796527993
2796627994 console.log("The first text box in document was deleted.");
2796727995 });
27996+ Word.Shape#select:member(1):
27997+ - >-
27998+ // Link to full sample:
27999+ https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/group-ungroup.yaml
28000+
28001+
28002+ await Word.run(async (context) => {
28003+ // Groups the shapes (including text boxes) found in the document body.
28004+ const shapes: Word.ShapeCollection = context.document.body.shapes.getByTypes([
28005+ Word.ShapeType.geometricShape,
28006+ Word.ShapeType.textBox,
28007+ ]);
28008+ shapes.load("items");
28009+ await context.sync();
28010+
28011+ const numShapes = shapes.items.length;
28012+ if (numShapes === 0) {
28013+ console.log("No shapes found in document body.");
28014+ return;
28015+ }
28016+
28017+ console.log(`Number of shapes to group: ${numShapes}`);
28018+
28019+ const groupedShape: Word.Shape = shapes.group();
28020+ groupedShape.load("shapeGroup/shapes");
28021+ await context.sync();
28022+
28023+ const shapeGroup: Word.ShapeGroup = groupedShape.shapeGroup;
28024+ console.log("Shapes grouped:", shapeGroup.shapes);
28025+ groupedShape.select();
28026+ });
2796828027Word.Shape#body:member:
2796928028 - >-
2797028029 // Link to full sample:
@@ -28224,6 +28283,37 @@ Word.ShapeCollection#getFirstOrNullObject:member(1):
2822428283 : `Text in first text box: ${shape.body.text}`
2822528284 );
2822628285 });
28286+ Word.ShapeCollection#group:member(1):
28287+ - >-
28288+ // Link to full sample:
28289+ https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/group-ungroup.yaml
28290+
28291+
28292+ await Word.run(async (context) => {
28293+ // Groups the shapes (including text boxes) found in the document body.
28294+ const shapes: Word.ShapeCollection = context.document.body.shapes.getByTypes([
28295+ Word.ShapeType.geometricShape,
28296+ Word.ShapeType.textBox,
28297+ ]);
28298+ shapes.load("items");
28299+ await context.sync();
28300+
28301+ const numShapes = shapes.items.length;
28302+ if (numShapes === 0) {
28303+ console.log("No shapes found in document body.");
28304+ return;
28305+ }
28306+
28307+ console.log(`Number of shapes to group: ${numShapes}`);
28308+
28309+ const groupedShape: Word.Shape = shapes.group();
28310+ groupedShape.load("shapeGroup/shapes");
28311+ await context.sync();
28312+
28313+ const shapeGroup: Word.ShapeGroup = groupedShape.shapeGroup;
28314+ console.log("Shapes grouped:", shapeGroup.shapes);
28315+ groupedShape.select();
28316+ });
2822728317Word.ShapeFill:class:
2822828318 - >-
2822928319 // Link to full sample:
@@ -28336,6 +28426,60 @@ Word.ShapeFillType:enum:
2833628426 console.log(`\tTransparency: ${moonFill.transparency}`);
2833728427 console.log(`\tFill type: ${moonFillType}`);
2833828428 });
28429+ Word.ShapeGroup:class:
28430+ - >-
28431+ // Link to full sample:
28432+ https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/group-ungroup.yaml
28433+
28434+
28435+ await Word.run(async (context) => {
28436+ // Groups the shapes (including text boxes) found in the document body.
28437+ const shapes: Word.ShapeCollection = context.document.body.shapes.getByTypes([
28438+ Word.ShapeType.geometricShape,
28439+ Word.ShapeType.textBox,
28440+ ]);
28441+ shapes.load("items");
28442+ await context.sync();
28443+
28444+ const numShapes = shapes.items.length;
28445+ if (numShapes === 0) {
28446+ console.log("No shapes found in document body.");
28447+ return;
28448+ }
28449+
28450+ console.log(`Number of shapes to group: ${numShapes}`);
28451+
28452+ const groupedShape: Word.Shape = shapes.group();
28453+ groupedShape.load("shapeGroup/shapes");
28454+ await context.sync();
28455+
28456+ const shapeGroup: Word.ShapeGroup = groupedShape.shapeGroup;
28457+ console.log("Shapes grouped:", shapeGroup.shapes);
28458+ groupedShape.select();
28459+ });
28460+ Word.ShapeGroup#ungroup:member(1):
28461+ - >-
28462+ // Link to full sample:
28463+ https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/group-ungroup.yaml
28464+
28465+
28466+ await Word.run(async (context) => {
28467+ // Ungroups the first set of grouped shapes (including text boxes) found in the document body.
28468+ const firstShapeGroup: Word.Shape = context.document.body.shapes.getByTypes([Word.ShapeType.group]).getFirstOrNullObject();
28469+ firstShapeGroup.load("shapeGroup/shapes");
28470+ await context.sync();
28471+
28472+ if (firstShapeGroup.isNullObject) {
28473+ console.log("No shape groups found in the document body.");
28474+ return;
28475+ }
28476+
28477+ let shapeGroup: Word.ShapeGroup = firstShapeGroup.shapeGroup;
28478+ console.log("About to ungroup first shape group found in document body:", shapeGroup.shapes);
28479+ shapeGroup.ungroup();
28480+
28481+ console.log("Ungrouped first shape group.");
28482+ });
2833928483Word.ShapeTextOrientation:enum:
2834028484 - >-
2834128485 // Link to full sample:
0 commit comments