We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to move the cursor to the table's cell and insert text using .NET


this is my code:


        Document docIndex = new Document("example.docx");
        DocumentBuilder builder = new DocumentBuilder(docIndex);
        builder.MoveToCell(4, 0, 0, 0);

here is my document: example.zip (90.8 KB)

When I try to move the cell of the fifth table, I get this exception:
Exception thrown: ‘System.ArgumentOutOfRangeException’ in Aspose.Words.dll
Additional information: Specified argument was out of the range of valid values. occurred

As you can see, this document has 5 tables and two sections.

Can you help me ?

Kind regards,


The DocumentBuilder.MoveToSection method moves the cursor to the beginning of the body in a specified section. Please use the following code example to get the desired output.

Document docIndex = new Document(MyDir + "example.docx");
DocumentBuilder builder = new DocumentBuilder(docIndex);
builder.MoveToCell(0, 0, 0, 0);

docIndex.Save(MyDir + "output.docx");