Free Support Forum -

Remove Shape Nodes from Word document programmatically


We have word documents which contains Shapes, the shapes have been used to creates lines

How can we programmatically remove the shapes from a word document



Thanks for your inquiry. The shape is imported as Shape node into Aspose.Words’ DOM. Please use Shape.Remove method to remove it from the document.

If you want to remove all shapes from the document, please use following code example.

Document doc = new Document(MyDir + @"in.docx");
doc.GetChildNodes(NodeType.Shape, true).Clear();