Skip to content

Instantly share code, notes, and snippets.

@fileformat-words-gists
Last active December 31, 2024 12:36
Show Gist options
  • Save fileformat-words-gists/faa19b5b112016ee1c5e06a5cb51f870 to your computer and use it in GitHub Desktop.
Save fileformat-words-gists/faa19b5b112016ee1c5e06a5cb51f870 to your computer and use it in GitHub Desktop.
Modify Word Group Shapes
// Prerequisite: Install <a href="https://www.nuget.org/packages/FileFormat.Words">FileFormat.Words</a>.
// Load the Word Document
var doc = new FileFormat.Words.Document($"WordGroupShapes.docx");
// Initialize the body with the loaded document.
var body = new FileFormat.Words.Body(doc);
// Load all group shapes
var groupShapes = body.GroupShapes;
// Traverse through each shape, change the shape type to hexagone and update document.
foreach (var groupShape in groupShapes)
{
groupShape.Shape1.Type = FileFormat.Words.IElements.ShapeType.Hexagone;
groupShape.Shape2.Type = FileFormat.Words.IElements.ShapeType.Hexagone;
doc.Update(groupShape);
}
// Save the modified Word Document
doc.Save($"ModifiedWordGroupShapes.docx");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment