Lock Shape’s Anchor Point to Paragraph in Word DOCX Document using C# .NET

I need to know how to get all the shapes inside anchor?

In ms word ill get it using the below code

 shp.LockAnchor = False

But i’m not sure how to do the same in aspose.


The Shape.AnchorLocked property can be used to specify whether the shape’s anchor should be locked or not. Secondly, the following C# code of Aspose.Words for .NET will store Shapes’ anchor Paragraph in an ArrayList:

Document doc = new Document("C:\\temp\\input.docx");

ArrayList list_Of_Anchor_Paragraphs = new ArrayList();
foreach (Shape shape in doc.GetChildNodes(NodeType.Shape, true))
    Paragraph anchorParagraph = (Paragraph)shape.GetAncestor(NodeType.Paragraph);
    if (anchorParagraph != null)

Hi Hafeez,

Did you mean shape.GetAncestor() function will always return null if if the shape is not part of anchor?

Let me know if my understanding is correct?


If the Shape is anchored to a Paragraph (child of Paragraph) then it will not return a Null Paragraph. Please ZIP and upload your sample Word document (containing Shape for which you are receiving NULL) here for testing. We will then investigate the issue on our end and provide you more information.