I’m trying to use Aspose.Words to retrieve the text from a text box in a docx file, but cannot seem to do so. I looked in the Aspose.Words helpfile but didn’t see anything related to text boxes. I’ve attached the file for your own testing? Could you tell me how to retrieve the text from such an object?
Thanks for your request. Text Box in your document is just a Shape. If you would like to find such objects and get text, you can use code like the following:
// Open document.
Document doc = new Document(@"Test001\in.docx");
// Get all shape.
NodeCollection shapes = doc.GetChildNodes(NodeType.Shape, true);
// Loop through all shapes.
foreach(Shape shape in shapes)
// Print test of the shape if it is text box.
if (shape.ShapeType == ShapeType.TextBox)
Hope this helps.